How do I protect a .bat from being erased? [on hold]
I have a batch that contain coding that would allow me to protect a secure
folder with password but I'm worried if the batch is erased intentionally
I may not be able to retrieve the file that the batch has password
protected.
Is there a way I can secure this batch file without using things like user
premission etc. Since I am going to be using this batch file on a memory
stick on different computers.
Monday, 30 September 2013
help with bash, password delete script
help with bash, password delete script
I would like to make a script that deletes a directory with 'rmdir' after
confirming with a password useing 'read' to set the variable.
so far i have this:
!/bin/bash -x
echo "Password:"
read -t 30 S1
S2='55555'
if [ $S1=$S2 ]; then
rmdir /home/william/test
else
echo "fail"
sleep 10
fi
so i have the "-x" to try to debug it but every time the script either
fails to echo(if i put the password in wrong) or it wont remove the
directory needed.
if someone has a modifiable script that i could use or if you could point
out the problems with the current script that would be great.
I would like to make a script that deletes a directory with 'rmdir' after
confirming with a password useing 'read' to set the variable.
so far i have this:
!/bin/bash -x
echo "Password:"
read -t 30 S1
S2='55555'
if [ $S1=$S2 ]; then
rmdir /home/william/test
else
echo "fail"
sleep 10
fi
so i have the "-x" to try to debug it but every time the script either
fails to echo(if i put the password in wrong) or it wont remove the
directory needed.
if someone has a modifiable script that i could use or if you could point
out the problems with the current script that would be great.
Trying to Pass an Intent from a SherlockActivity to a SherlockFragment
Trying to Pass an Intent from a SherlockActivity to a SherlockFragment
I want to pass an intent from my SherlockActivity to my SherlockFragment
but I am not getting a clue on how to do this. I want to pass the
CategoryID in MaterialsActivity to BooksFragment below. The code of the
MaterialActivity is below and at the far end the BooksFragment is pasted.
public class MaterialsActivity extends SherlockFragmentActivity{
String categoryID = null;
Context context = null;
Resources resources = null;
IDatabaseHelper databaseHelper = null;
// store the active tab here
public static String ACTIVE_TAB = "activeTab";
//Initializing the Tab Fragments that would be added to this view
AudiosFragment audioFragment = null;
BooksFragment bookFragment = null;
VideosFragment videoFragment = null;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
//setContentView(R.layout.materials);
Intent intent = getIntent();
categoryID = intent.getExtras().getString("categoryID");
context = MaterialsActivity.this;
resources = getResources();
databaseHelper = new DatabaseHelper(context);
final ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// add tabs
Tab tab1 = actionBar.newTab()
.setText("Books")
.setTabListener(new BooksListener<BooksFragment>(
this, "book", BooksFragment.class));
actionBar.addTab(tab1);
// check if there is a saved state to select active tab
if( savedInstanceState != null ){
getSupportActionBar().setSelectedNavigationItem(
savedInstanceState.getInt(ACTIVE_TAB));
}
new CollectMaterials(context,resources).execute();
}
//This is the BooksFragment Listener that would make the Tab
components to listener to a tab click events
public class BooksListener<T extends SherlockListFragment>
implements ActionBar.TabListener{
private BooksFragment mFragment;
private final Activity mActivity;
private final String mTag;
private final Class<T> mClass;
public BooksListener(Activity activity, String tag, Class<T>
clz) {
mActivity = activity;
mTag = tag;
mClass = clz;
}
public void onTabSelected(Tab tab, FragmentTransaction ft) {
// Check if the fragment is already initialized
if (mFragment == null) {
// If not, instantiate and add it to the activity
mFragment = (BooksFragment) Fragment.instantiate(
mActivity, mClass.getName());
// mFragment..setProviderId(mTag); // id for event provider
ft.add(android.R.id.content, mFragment, mTag);
} else {
// If it exists, simply attach it in order to show it
ft.attach(mFragment);
}
}
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
if (mFragment != null){
// Detach the fragment, because another one is being
attached
ft.detach(mFragment);
}
}
public void onTabReselected(Tab tab, FragmentTransaction ft) {
// User selected the already selected tab. Usually do
nothing.
}
}
}
//This is my fragment code below. I would to get the CategoryID here
public class BooksFragment extends SherlockListFragment{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup
container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.books, container, false);
// do your view initialization here
return view;
}
}
I want to pass an intent from my SherlockActivity to my SherlockFragment
but I am not getting a clue on how to do this. I want to pass the
CategoryID in MaterialsActivity to BooksFragment below. The code of the
MaterialActivity is below and at the far end the BooksFragment is pasted.
public class MaterialsActivity extends SherlockFragmentActivity{
String categoryID = null;
Context context = null;
Resources resources = null;
IDatabaseHelper databaseHelper = null;
// store the active tab here
public static String ACTIVE_TAB = "activeTab";
//Initializing the Tab Fragments that would be added to this view
AudiosFragment audioFragment = null;
BooksFragment bookFragment = null;
VideosFragment videoFragment = null;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
//setContentView(R.layout.materials);
Intent intent = getIntent();
categoryID = intent.getExtras().getString("categoryID");
context = MaterialsActivity.this;
resources = getResources();
databaseHelper = new DatabaseHelper(context);
final ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// add tabs
Tab tab1 = actionBar.newTab()
.setText("Books")
.setTabListener(new BooksListener<BooksFragment>(
this, "book", BooksFragment.class));
actionBar.addTab(tab1);
// check if there is a saved state to select active tab
if( savedInstanceState != null ){
getSupportActionBar().setSelectedNavigationItem(
savedInstanceState.getInt(ACTIVE_TAB));
}
new CollectMaterials(context,resources).execute();
}
//This is the BooksFragment Listener that would make the Tab
components to listener to a tab click events
public class BooksListener<T extends SherlockListFragment>
implements ActionBar.TabListener{
private BooksFragment mFragment;
private final Activity mActivity;
private final String mTag;
private final Class<T> mClass;
public BooksListener(Activity activity, String tag, Class<T>
clz) {
mActivity = activity;
mTag = tag;
mClass = clz;
}
public void onTabSelected(Tab tab, FragmentTransaction ft) {
// Check if the fragment is already initialized
if (mFragment == null) {
// If not, instantiate and add it to the activity
mFragment = (BooksFragment) Fragment.instantiate(
mActivity, mClass.getName());
// mFragment..setProviderId(mTag); // id for event provider
ft.add(android.R.id.content, mFragment, mTag);
} else {
// If it exists, simply attach it in order to show it
ft.attach(mFragment);
}
}
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
if (mFragment != null){
// Detach the fragment, because another one is being
attached
ft.detach(mFragment);
}
}
public void onTabReselected(Tab tab, FragmentTransaction ft) {
// User selected the already selected tab. Usually do
nothing.
}
}
}
//This is my fragment code below. I would to get the CategoryID here
public class BooksFragment extends SherlockListFragment{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup
container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.books, container, false);
// do your view initialization here
return view;
}
}
ttk widgets in frame not displayed
ttk widgets in frame not displayed
I'm having some difficulty with Python and ttk. I built a UI that works
correctly, but looks a bit cluttered. I wanted to add a frame so I could
add some padding and enable resizing and so on, but now none of the
widgets are displayed. My code is below.
Previously I was just passing parent as the parent to the widgets, which
did work. I've been working through a few tutorials, and I can't see
anything obviously wrong, though I'm sure it's something simple.
class Application:
def __init__(self, parent):
self.parent = parent
self.content = ttk.Frame(parent, padding=(3,3,12,12))
self.content.columnconfigure(1, weight=1)
self.content.rowconfigure(1, weight=1)
self.row1()
def row1(self):
self.enButton = ttk.Button(self.content, text="Enable",
command=self.enableCmd)
self.disButton = ttk.Button(self.content, text="Disable",
command=self.disableCmd)
self.enButton.grid(column=1, row=1)
self.disButton.grid(column=2, row=1)
self.disButton.state(['disabled'])
if __name__ == '__main__':
root = Tk()
root.title("Wilton Control Interface")
img = Image("photo", file="appicon.gif")
root.tk.call('wm','iconphoto',root._w,img)
app = Application(root)
root.mainloop()
I'm having some difficulty with Python and ttk. I built a UI that works
correctly, but looks a bit cluttered. I wanted to add a frame so I could
add some padding and enable resizing and so on, but now none of the
widgets are displayed. My code is below.
Previously I was just passing parent as the parent to the widgets, which
did work. I've been working through a few tutorials, and I can't see
anything obviously wrong, though I'm sure it's something simple.
class Application:
def __init__(self, parent):
self.parent = parent
self.content = ttk.Frame(parent, padding=(3,3,12,12))
self.content.columnconfigure(1, weight=1)
self.content.rowconfigure(1, weight=1)
self.row1()
def row1(self):
self.enButton = ttk.Button(self.content, text="Enable",
command=self.enableCmd)
self.disButton = ttk.Button(self.content, text="Disable",
command=self.disableCmd)
self.enButton.grid(column=1, row=1)
self.disButton.grid(column=2, row=1)
self.disButton.state(['disabled'])
if __name__ == '__main__':
root = Tk()
root.title("Wilton Control Interface")
img = Image("photo", file="appicon.gif")
root.tk.call('wm','iconphoto',root._w,img)
app = Application(root)
root.mainloop()
Sunday, 29 September 2013
Q.js any() function
Q.js any() function
Is there a way for Q.js to wait until any promise has finished, whether it
has succeeded or not? Maybe there's an obvious way of doing this, as I
can't find an appropriate library function in the docs, but I'm not sure
how to.
Is there a way for Q.js to wait until any promise has finished, whether it
has succeeded or not? Maybe there's an obvious way of doing this, as I
can't find an appropriate library function in the docs, but I'm not sure
how to.
Notify friends of a user who starts using your facebook app
Notify friends of a user who starts using your facebook app
I realize this is a bit vague, but I have no idea where to even begin
searching for this. I know for a fact that when a user registers on
"Circle" using facebook they somehow have found a way to notify all of
that users facebook friends that they joined Circle or at the very least
it notify all of a users friends who also registered with circle that they
joined. How did they accomplish this using the Facebook SDK?
One more time to be perfectly clear: Currently when one of my friends
registers with the social app "Circle" using facebook I end up getting a
notification on Facebook telling me "Joe Smith joined Circle" and I would
like to know how to get my app to do the same thing using the fb sdk
I realize this is a bit vague, but I have no idea where to even begin
searching for this. I know for a fact that when a user registers on
"Circle" using facebook they somehow have found a way to notify all of
that users facebook friends that they joined Circle or at the very least
it notify all of a users friends who also registered with circle that they
joined. How did they accomplish this using the Facebook SDK?
One more time to be perfectly clear: Currently when one of my friends
registers with the social app "Circle" using facebook I end up getting a
notification on Facebook telling me "Joe Smith joined Circle" and I would
like to know how to get my app to do the same thing using the fb sdk
How does Float round when converting it into integer
How does Float round when converting it into integer
If I have
(float)value = 10.50
and do
int new_value = (int)value
what rules will round number?
If I have
(float)value = 10.50
and do
int new_value = (int)value
what rules will round number?
Subscribe to:
Posts (Atom)