Skip to content

Instantly share code, notes, and snippets.

View pgilad's full-sized avatar
🔭

Gilad Peleg pgilad

🔭
View GitHub Profile
@jeroensmeets
jeroensmeets / gist:6e17fc17b5cb156d24f90f222cd9d9e9
Created May 1, 2017 07:38
essential parts for let's encrypt renewal under nginx
server {
listen 80;
# set root and server_name here
# only serve validation files for Let's Encrypt on port 80
location /.well-known/acme-challenge/ {
try_files $uri /dev/null =404;
}
# otherwise to SSL
@kjantzer
kjantzer / backbone.collection.saveToCSV.js
Last active May 14, 2017 10:21
Backbone.Collection.saveToCSV() — adds ability to save all of the collections models as a CSV file. NOTE: only tested on Chrome; may not work on all browsers, but would work well for packaged Chrome apps.
/*
Save To CSV 0.0.2
@author Kevin Jantzer, Blackstone Audio
@since 2015-01-16
intial code from http://stackoverflow.com/a/14966131/484780
TODO
- needs improved (objects as values)
@mistakster
mistakster / webpack.config.js
Created July 9, 2015 16:23
Webpack configuration file
/**
* Build for production:
* $ NODE_ENV=production webpack
*
* Build for staging or development mode
* $ webpack
*
* Run app server in dev mode and use Hot Module Replacement
* $ NODE_ENV=webpack nodemon --watch ./app index.js
*
@pgilad
pgilad / create-temp-dir.yml
Created October 27, 2015 15:08
Create a temp dir cross-platform in ansible
- name: create a local temp directory
local_action:
module: command mktemp -d "{{ lookup('env', 'TMPDIR') | default('/tmp/') }}ansible.XXXX"
register: mktemp_output
@pgilad
pgilad / gulpfile.js
Last active November 27, 2017 21:44
gulpfile regular flow
var path = require('path');
var gulp = require('gulp');
var streamqueue = require('streamqueue');
var $gulp = require('gulp-load-plugins')({
lazy: false
});
var prependBowerPath = function (package) {
return path.join('./src/bower_components/', package);
};
@equinoxel
equinoxel / main.scss
Created January 23, 2017 10:37
webpack 2 config capable of loading font-awesome fonts
@import "~normalize-scss/sass/normalize";
$fa-font-path: "~font-awesome/fonts";
@import "~font-awesome/scss/font-awesome.scss";
@import "bourbon";
@pgilad
pgilad / word_count.hs
Created December 16, 2017 20:28
Dictionary word count in Haskell
import Data.List
import qualified Data.Map.Strict as Map
import Data.Ord (comparing)
wordFrequency :: (Ord a) => [a] -> Map.Map a Int
wordFrequency xs = foldr (\word acc -> Map.insertWith (+) word 1 acc) Map.empty xs
nBiggest :: Int -> Map.Map a Int -> [(a, Int)]
nBiggest n m = take n $ sortBy (comparing $ negate . snd) $ Map.toList m
@pgilad
pgilad / chi_square_min_sample.r
Last active April 15, 2018 10:28
Find minimum sample size to obtain minimum power test in non-centralized chi-square
u <- c(0.1, 0.3, 0.5)
chi_df <- 3
target_power <- 0.9
chi_base <- qchisq(0.95, chi_df)
get_power <- function(n) {
return (pchisq(q = chi_base, df = chi_df, ncp = n * u %*% u, lower.tail = FALSE))
}
get_power(20)
@iiska
iiska / convert.py
Created October 24, 2012 12:56
Convert sample.jtl to csv
#! /usr/bin/env python
from xml.etree import ElementTree
from xml.sax.handler import ContentHandler
from xml.sax import parse
import csv