Skip to content

Instantly share code, notes, and snippets.

@yehosef
yehosef / optimization.php
Last active October 7, 2018 13:55
RF interview followup
<?php
$series_sizes = [10, 100, 200, 300, 1000, 10000];
//$series_sizes = [10, 100];
$range_max = 3;
foreach ($series_sizes as $series_size)
{
$series_arr[$series_size] = generate_series($series_size, $range_max * -1, $range_max);
set @sum=0;
select mea1_count, num_members, @sum:=@sum+num_members from (
SELECT
mea1_count,
count(mem_id) num_members
FROM (
SELECT
mea1.mem_id,
count(mea1.id) mea1_count
@yehosef
yehosef / 0_reuse_code.js
Last active August 29, 2015 14:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@yehosef
yehosef / del_too_small.sh
Last active August 29, 2015 14:24
delete files smaller than x b
find . -size -$1b -delete
@yehosef
yehosef / date_dirs.sh
Last active August 29, 2015 14:24
organized files by date
#!/bin/bash
years=`seq 2014 2015`
months=`seq -w 01 12`
for year in ${years[@]}; do
mkdir $year
for month in ${months[@]}; do
mkdir $year/$month
mv $year-$month-* $year/$month
done
@yehosef
yehosef / show all color.sh
Last active August 29, 2015 14:23
show console colors for tmux
#!/usr/bin/env bash
for i in {0..255} ; do printf "\x1b[38;5;${i}mcolour${i}\n"; done
@yehosef
yehosef / query.json
Last active November 22, 2016 21:03
elasticsearch avg problem
{
"size": 0,
"query": {
"filtered": {
"query": {
"query_string": {
"query": "*",
"analyze_wildcard": true
}
},
@yehosef
yehosef / es_position_offset_gap_test
Last active August 29, 2015 14:15
elasticsearch position_offset_gap on objects
DELETE /test
PUT /test
{
"mappings": {
"nospace": {
"properties": {
"id": {
"type": "integer"
},
@yehosef
yehosef / post-checkout
Last active December 19, 2016 09:28
git hook to update composer dependencies only if changed, and to put the current revision in a file
#!/bin/bash
#set -x
githooks/post-checkout-revision.sh
githooks/post-checkout-composer.sh
@yehosef
yehosef / gist:57df0ec37d5096222cf0
Last active August 29, 2015 14:04 — forked from remy/gist:350433
check for localStorage support and if its not there, make a polyfill based on cookies
// refer to https://gist.github.com/paulirish/5558557
try {
if (!window.localStorage || !window.sessionStorage) throw "exception";
localStorage.setItem('storage_test', 1);
localStorage.removeItem('storage_test');
} catch(e) {
(function () {
var Storage = function (type) {