Skip to content

Instantly share code, notes, and snippets.

View ilaif's full-sized avatar
🎯
Focusing

Ilai Fallach ilaif

🎯
Focusing
View GitHub Profile
load('ex3data1.mat'); % Loads X - The data-set to predict
load('ex3weights.mat'); % Loads Theta1, Theta2 - A trained Neural Network.
% Compute sigmoid function
function g = sigmoid(z)
g = 1.0 ./ (1.0 + exp(-z));
end
% The prediction function
function p = predict(Theta1, Theta2, X)
#!/bin/bash
#
# (1) copy to: ~/bin/ssh-host-color
# (2) set: alias ssh=~/bin/ssh-host-color
#
# Inspired from http://talkfast.org/2011/01/10/ssh-host-color
# Fork from https://gist.github.com/773849
#
set_term_bgcolor(){
// Restify Server CheatSheet.
// More about the API: http://mcavage.me/node-restify/#server-api
// Install restify with npm install restify
// 1.1. Creating a Server.
// http://mcavage.me/node-restify/#Creating-a-Server
var restify = require('restify');
@ilaif
ilaif / base.error.js
Created December 27, 2016 20:30
Generic BaseError
'use strict';
const logger = require('../libs/logger.lib');
const ErrorLevel = require('../enums/ErrorLevel');
const ErrorLevelInverse = require('../enums/ErrorLevelInverse');
const BaseError = exports.BaseError = class BaseError extends Error {
constructor(opts) {
let message = opts.message || 'Unknown Error';
@ilaif
ilaif / arazim_crawler.py
Last active March 26, 2017 15:20
A crawler to find new summaries in Arazim site and notify by email
#!/Library/Frameworks/Python.framework/Versions/2.7/bin/python
"""
Arazim Crawler
Description: A script that crawls arazim website for summaries, if a new summary is found, sends an email notification.
Usage:
1. pip install requirements: requests, beautifulsoup4
2. place script in desired folder
3. put it in crontab (crontab -e) with the contents (*/15 represents every 15 minutes):
@ilaif
ilaif / macos_bootstrap.sh
Last active November 12, 2018 15:56 — forked from nopcoder/macos_bootstrap.sh
Mac OS Bootstrap script to setup common developer tools and settings
#!/usr/bin/env bash
#
# Bootstrap script for setting up a new macOS machine
#
# Based on https://gist.github.com/codeinthehole/26b37efa67041e1307db
#
echo "##############################"
echo "#Welcome to MAC bootstrapper!#"
echo "##############################"
@ilaif
ilaif / original-code.rb
Created April 16, 2019 20:55
instrument-everything-blog-original-code
sub vcl_recv {
#FASTLY recv
if (req.method != "HEAD" && req.method != "GET" && req.method != "FASTLYPURGE") {
return(pass);
}
return(lookup);
}
@ilaif
ilaif / instrumented-code.rb
Created April 16, 2019 20:58
instrument-everything-instrumented-code
sub vcl_recv {
declare local var.log_8 BOOL;
declare local var.log_5 BOOL;
declare local var.log_4 BOOL;
#FASTLY recv
set var.log_4 = true;
if (req.request != "HEAD" && req.request != "GET" && req.request != "FASTLYPURGE") {
set var.log_5 = true;
log "syslog " req.service_id " Px-Instrumentation :: main," + if(var.log_4, "4 ", "") + if(var.log_5, "5 ", "");
return(pass);
@ilaif
ilaif / fetch-existing.py
Created April 16, 2019 20:59
instrument-everything-blog-fetch-existing
def get_all_custom_vcls(service_id, version):
url = 'https://api.fastly.com/service/{}/version/{}/vcl'.format(service_id, version)
response = requests.request('GET', url, headers={...})
return response.json()
@ilaif
ilaif / inject-instrumentation.py
Created April 16, 2019 21:01
instrument-everything-blog-inject-instrumentation
def add_instrumentation(name, content):
lines = content.split('\n')
original_line_count = 1
instrumented_lines = []
subroutine_parenthesis_stack = []
sub_tested_line_numbers = []
tested_line_numbers = []
cur_subroutine_decl_line_number = 0
in_subroutine = False
in_synthetic = False