Skip to content

Instantly share code, notes, and snippets.

View raam86's full-sized avatar

Raam Rosh-Hai raam86

  • Amsterdam, Netherlands
View GitHub Profile
@raam86
raam86 / arch_tips.md
Last active August 27, 2018 08:39
Arch Linux Installation Tips

Connect to wifi:

 wpa_supplicant -B -i interface -c $(wpa_passphrase MYNetwork)

UEFI BOOT:

fdisk -l

  • find the disk lablaed as UEFI and mount it
  • follow the syslinux installation instructions
  • make sure all the files are in EFI/syslinux espcially the .img and initram
@raam86
raam86 / clean_your_private_slack_messages.sh
Last active April 13, 2017 14:00
a short bash script to delete private messages between you and everybody else on slack
# pip install slack-cleaner
# users.json is the users file you get when you bulk export slack messeges
cat users.json | jq ".[].name" > users_list
while read name; do
temp="${name%\"}"
temp="${temp#\"}"
curr=$temp
echo $curr
slack-cleaner --token [YOUR_SECRET_TOKEN] --message --direct $curr --user [YOUR_USERNAME] --perform
sleep 2

I was looking for a way to make the guys and girls at FindHotel more interested in functional programming, and I always thought the NICTA course is a very pure form of FP.  After reading this, starting to program in haskell shouldn’t be scary anymore.  So let’s learn haskell in 3 steps:

Install Stack

curl -sSL https://get.haskellstack.org/ | sh

https://docs.haskellstack.org/en/stable/install_and_upgrade/#mac-os-x

@raam86
raam86 / get_ips.sh
Created January 12, 2016 17:37
Get all private ips in aws cluster for tag
#one liner bash
node -e 'for(var j=JSON.parse(process.argv[1]).Reservations,i=0;i<j.length;i++)for(var t=0;t<j[i].Instances.length;t++)console.log(j[i].Instances[t].PrivateIpAddress);' "$(aws ec2 describe-instances --filters 'Name=tag:cluster,Values=spark')"
var defaults = function(obj, source) {
for (var prop in source) {
if (obj[prop] === undefined) obj[prop] = source[prop];
}
return obj;
}
var stringifyGETParams = function(url, data) {
var query = '';
for (var key in data) {
@raam86
raam86 / gist:3036432db2b3f8edc9c8
Created January 26, 2015 12:58
Elastic curls
//Get most significant titles per country
curl -XGET 'localhost:9200/_search' -d '
{
"aggregations": {
"events": {
"terms": {"field": "countryName"},
"aggregations": {
"significantArist": {
"significant_terms": {"field": "title"}
@raam86
raam86 / htaccess redirect query
Created October 15, 2013 14:22
A simple function to convert origin and destination urls to htaccess rules.
function make_htaccess_query (query_string,destination) {
var parts = query_string.split('?');
return query = "RewriteCond %{REQUEST_URI} " + parts[0] + "\n"
+ "RewriteCond %{QUERY_STRING}" + parts[1] + "\n"
+ "RewriteRule ^(.*)$ " + destination + " [L,R=301]";
}
@raam86
raam86 / php_printer
Created October 13, 2013 20:14
Tired of <pre>$varialbe</pre>? Use this printer
function printer($val){
echo "<pre>";
var_dump($val);
echo "</pre>";
}
@raam86
raam86 / 301_generators
Created October 13, 2013 07:52
A simple script which takes an array of json objects and outputs 301 redirect for apache .htaccess
/**
* Takes an Origin and a Destination to concat a .htaccess
* 301 redirect string.
* @param {string} origin - orginal page
* @param {string} dest - destination page
* @return {string} - a 301 redirect phrase from origin to dest
*/
function make301(origin,dest){
return "redirect 301 " + origin + " " + dest;
}
@raam86
raam86 / redis benchmark
Last active December 23, 2015 15:49
redis benchmark on a 4 CPU XEON with 1gb ram
model name : Intel(R) Xeon(R) CPU E3-1240 V2 @ 3.40GHz
model name : Intel(R) Xeon(R) CPU E3-1240 V2 @ 3.40GHz
model name : Intel(R) Xeon(R) CPU E3-1240 V2 @ 3.40GHz
model name : Intel(R) Xeon(R) CPU E3-1240 V2 @ 3.40GHz
PING_INLINE: 0.00
PING_INLINE: 16132.78
====== PING_INLINE ======
10000 requests completed in 0.55 seconds