Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Destablizing Authoritarian governments to ₿UIDL ₿ack ₿etter

nolim1t - f6287b82CC84bcbd nolim1t

💭
Destablizing Authoritarian governments to ₿UIDL ₿ack ₿etter
View GitHub Profile
View gist:114115
-(NSDictionary *)readDatafile:(NSString *)plistfile {
NSLog(@"Reading PLIST file %@", plistfile);
return [[NSDictionary alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:plistfile ofType:@"plist"]];
}
View occurances.py
def countwordsInString(string, delimiter, word):
occurs = 0
stringarray = string.split(delimiter)
for stringword in stringarray:
if word == stringword:
occurs = occurs + 1
return occurs
@nolim1t
nolim1t / gist:121282
Created Jun 1, 2009
Count the number of occurances in a string
View gist:121282
<?php
function countwordsInString($string, $delimiter, $word) {
$occurs = 0;
foreach (explode($delimiter, $string) as $stringword) if ($word == $stringword) $occurs++;
return $occurs;
}
?>
@nolim1t
nolim1t / gist:121949
Created Jun 2, 2009
Show all txt files in the Downloads directory
View gist:121949
<?php
foreach (scandir("Downloads") as $f) if ((substr($f, -3, 3) == "txt" || substr($f, -3, 3) == "csv") && stristr(strtolower($f), "errors")) echo $f."\n";
?>
@nolim1t
nolim1t / gist:122068
Created Jun 2, 2009
Strip out windows linebreaks
View gist:122068
perl -pi -e "s/\r\n/\n/" $1
View gist:122092
<?php
$memcache = new Memcache;
$memcache->connect('a.b.c.d', 11211);
$memcache->set('test', 'This could be an array or an object (the methods wont get saved!', false, 600);
$retrieval = $memcache->get('test');
if ($retrieval) print_r($retrieval);
?>
@nolim1t
nolim1t / gist:122904
Created Jun 3, 2009
VBScript code to show when a file was last modified
View gist:122904
Set fso = CreateObject(Scripting.FileSystemObject)
Set f = fso.GetFile("Path\to\file")
MsgBox CLng(DateDiff("s", f.DateLastModified, Now))
View gist:123507
<?php
foreach ($cmds as $cmd) {
$pid=pcntl_fork();
if ($pid) {
exec($cmd);
break;
}
}
?>
@nolim1t
nolim1t / gist:126220
Created Jun 9, 2009
Bonus points if you work out what this Perl does!
View gist:126220
for($a=1;$a<=11;$a++){if($a==1){print "h";}elsif($a==2){print "e";}elsif($a==3 or $a==4 or $a==10){print "l";}elsif($a==5 or $a==8){print "o";}elsif($a==11){print "d";}elsif($a==7){print "w";}elsif($a==9){print "r";}else{print " ";}}
@nolim1t
nolim1t / gist:126455
Created Jun 9, 2009
Quality Center OTA via PHP
View gist:126455
<?php
// Found this on the web
// Requirements: PHP + COM + Win32 (duh)
// DISCLAIMER: Found this on the web. Have not tested this yet, but it would come in handy
$qcurl =$_GET["qcurl"];
$usr =$_GET["usr"];
$pwd =$_GET["pwd"];
$dmn =$_GET["dmn"];