This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Converts a mysql DateTime String to java Calendar | |
* @param dateString | |
* @return Calendar | |
*/ | |
public static Calendar mysqlDateTimeToCalendar(String dateString) | |
{ | |
try | |
{ | |
//in my case I hade an . in the end of the date String. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ps aux | grep "text" | awk '{print $2}' | xargs kill |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def download_file(url, local_file): | |
u = urllib2.urlopen(url) | |
f = open(local_file , 'wb') | |
meta = u.info() | |
file_size = int(meta.getheaders("Content-Length")[0]) | |
print "Downloading: %s Bytes: %s" % (local_file , file_size) | |
file_size_dl = 0 | |
block_sz = 8192 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def delete_directory_contents(folder): | |
for the_file in os.listdir(folder): | |
file_path = os.path.join(folder, the_file) | |
try: | |
if os.path.isfile(file_path): | |
os.unlink(file_path) | |
elif os.path.isdir(file_path): shutil.rmtree(file_path) | |
except Exception, e: | |
print e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main() | |
{ | |
//Why is this happening ????????? | |
float x = 0.1; | |
while (x!=1.1) | |
{ | |
printf("x = %f\n", x); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#repeat x times | |
#run 5 ls - runs ls 5 times | |
function run() { | |
number=$1 | |
shift | |
for n in $(seq $number); do | |
$@ | |
sleep 1 | |
done | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Clean database. Truncates all tables except from everything that loads with fixtures. | |
* Used as a fast clean. | |
*/ | |
public function cleanDB() | |
{ | |
$excludeTables = array(); | |
$em = $this->em; | |
$connection = $em->getConnection(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//this: https://help.directadmin.com/item.php?id=589 | |
$dirs = scandir('/home/'); | |
shuffle($dirs); | |
$ignoreDirs = [ | |
'.', | |
'..', | |
'tmp', | |
'ftp', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#- if use a different port, change the port. | |
rsync -av -exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found} -z --rsh='ssh -p22' --delete --progress --exclude [email protected] /local/destination |
OlderNewer