Skip to content

Instantly share code, notes, and snippets.

View samermurad's full-sized avatar

Samer Murad samermurad

View GitHub Profile
@Neil-Smithline
Neil-Smithline / idletime.sh
Created March 18, 2012 15:33
Mac OS X Idle Time Shell Script
#!/bin/sh
# Get MacOSX idletime. Shamelessly stolen from http://bit.ly/yVhc5H
/usr/sbin/ioreg -c IOHIDSystem | /usr/bin/awk '/HIDIdleTime/ {print int($NF/1000000000); exit}'
@aheckmann
aheckmann / storeImgInMongoWithMongoose.js
Created April 17, 2012 19:14
store/display an image in mongodb using mongoose/express
/**
* Module dependencies
*/
var express = require('express');
var fs = require('fs');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
// img path
@richieforeman
richieforeman / makeauthority.sh
Created July 23, 2012 21:38
Issue Your Own Self-Signed S/MIME Certs with OpenSSL
# Run this once
openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
--# Main
-- Skeletal Animation
--helper function for matrix vector maths
function matrixByVector(m, v)
m=m:transpose()
vx = vec4(m[1], m[2], m[3], m[4]):dot(v)
vy = vec4(m[5], m[6], m[7], m[8]):dot(v)
vz = vec4(m[9], m[10], m[11], m[12]):dot(v)
vw = vec4(m[13], m[14], m[15], m[16]):dot(v)
@6174
6174 / Random-string
Created July 23, 2013 13:36
Generate a random string in JavaScript In a short and fast way!
//http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
@woods
woods / gen-key-script
Last active June 26, 2024 00:37
Creating gpg keys non-interactively
Key-Type: 1
Key-Length: 2048
Subkey-Type: 1
Subkey-Length: 2048
Name-Real: Root Superuser
Name-Email: root@handbook.westarete.com
Expire-Date: 0
@wyatt8740
wyatt8740 / sdljoytest.cpp
Created February 21, 2014 16:34
SDL Joystick Button ID finder
/* SDLJOYTEST
Prints the ID numbers of SDL input devices when activated.
EXAMPLE: if you are trying to find the SDL button ID of the 'A' button on
an imaginary gamepad or joystick, run this program and then press
the 'A' button on your joystick. As long as it is working properly,
the program will print the IDs of whatever buttons are being held down,
allowing you to enter that ID into a config file for inputs.
So say the 'A' button prints an ID of '5'. That means that the ID
5 is what you should enter for the config file.
@lastguest
lastguest / JSON_to_URLEncoded.js
Created July 10, 2014 17:47
Convert JavaScript object to x-www-form-urlencoded format
function JSON_to_URLEncoded(element,key,list){
var list = list || [];
if(typeof(element)=='object'){
for (var idx in element)
JSON_to_URLEncoded(element[idx],key?key+'['+idx+']':idx,list);
} else {
list.push(key+'='+encodeURIComponent(element));
}
return list.join('&');
}
@gskielian
gskielian / git-specify-ssh-key
Created October 14, 2014 16:51
Specifying SSH Key within Git Clone
#how to specify an ssh key to use when cloning a repo in Mac
ssh-agent bash -c 'ssh-add /Users/UR_USERNAME/.ssh/UR_PRIVATE_KEY; git clone git@DAS_GIT_URL'
@MihaelIsaev
MihaelIsaev / HMAC.swift
Last active December 4, 2019 04:51
Easy to use Swift implementation of CommonCrypto HMAC. You can easily hash your String to: md5, sha1, sha224, sha256, sha384, sha512 with pure Swift.
//
// HMAC.swift
//
// Created by Mihael Isaev on 21.04.15.
// Copyright (c) 2014 Mihael Isaev inc. All rights reserved.
//
// ***********************************************************
//
// How to import CommonCrypto in Swift project without Obj-c briging header
//