Skip to content

Instantly share code, notes, and snippets.

View sumardi's full-sized avatar
🏠
Working from home

Sumardi Shukor sumardi

🏠
Working from home
View GitHub Profile
Array.prototype.countCattle = function(type) {
var count = 0;
for(var i = 0; i < this.length; i++) {
if (type == this[i].type) {
count++;
}
}
return count;
function warningMaker( obstacle , zones ){
var count = 0;
return function ( number, location ) {
count++;
zones.push(location);
alert("Beware! There have been " +
obstacle +
" sightings in the Cove today!\n" +
number +
" " +
@sumardi
sumardi / gist:8242698
Created January 3, 2014 17:49
What is obtained when the result of passing 9 into function 4 is then passed into the function whose array index matches the result of passing 3 into function 2?
var puzzlers = [
function ( a ) { return 8*a - 10; },
function ( a ) { return (a-3) * (a-3) * (a-3); },
function ( a ) { return a * a + 4; },
function ( a ) { return a % 5; }
];
alert((puzzlers[(puzzlers[1])(3)])((puzzlers[3])(9)));
@sumardi
sumardi / gist:7262563
Created November 1, 2013 08:43
Fix llvm-3.0 update problems on OS X Mavericks
sudo port install llvm-3.3
sudo port install ld64 +llvm33
sudo port install cctools +llvm33
sudo port upgrade outdated
@sumardi
sumardi / gist:6971875
Created October 14, 2013 07:06
AppleDoc Run Script.
/usr/local/bin/appledoc \
--project-name "${PROJECT_NAME}" \
--project-company "Software Machine Development" \
--company-id "com.sumardi" \
--output "~/Projects/Help/${PROJECT_NAME}" \
--install-docset \
--logformat xcode \
--keep-undocumented-objects \
--keep-undocumented-members \
--keep-intermediate-files \
@sumardi
sumardi / gist:6633298
Created September 20, 2013 04:27
Fix locale setting on EC2
# add this line to /etc/environment; then reboot
LC_ALL="en_US.UTF-8"
@sumardi
sumardi / supervisord.conf
Created July 7, 2013 08:48
Laravel 4 queue listener with supervisord.
[unix_http_server]
file=/var/run//supervisor.sock ; (the path to the socket file)
chmod=0700 ; sockef file mode (default 0700)
[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
; the below section must remain in the config file for RPC
@sumardi
sumardi / gist:5721069
Created June 6, 2013 12:14
Force UIViewController to portrait orientation in iOS 6. Create a new category from UINavigationController and override the rotation methods.
-(BOOL)shouldAutorotate
{
return [self.topViewController shouldAutorotate];
}
-(NSUInteger)supportedInterfaceOrientations
{
return [self.topViewController supportedInterfaceOrientations];
}
@sumardi
sumardi / gist:5689747
Created June 1, 2013 09:00
AWS S3 Sample Policy
{
"Version": "2008-10-17",
"Id": "my-id",
"Statement": [
{
"Sid": "Allow get requests to specific referrers",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
@sumardi
sumardi / gist:5559896
Created May 11, 2013 12:56
Subdirectory checkouts with Git sparse-checkout
# New repository
mkdir <repo> && cd <repo>
git init
git remote add –f <name> <url>
git config core.sparsecheckout true
echo some/dir/ >> .git/info/sparse-checkout
echo another/sub/tree >> .git/info/sparse-checkout
git pull <remote> <branch>
# Existing repository