Skip to content

Instantly share code, notes, and snippets.

View skhavari's full-sized avatar
💭
I may be slow to respond.

Sam Khavari skhavari

💭
I may be slow to respond.
View GitHub Profile
@skhavari
skhavari / montyHallSim.js
Created June 5, 2022 18:01
proving to the kids you should always switch doors....
const rand = (min, max) => Math.floor(Math.random() * (max - min + 1) + min);
const setRemove = (list, r1, r2) => {
let temp = new Set(list);
temp.delete(r1);
temp.delete(r2);
return [...temp];
};
const GOAT = '🐐';
const PRIZE = '🚗';
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Fax Image Maker</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css" />
<style>
html,
body {
@skhavari
skhavari / trace.md
Created November 7, 2015 22:29
Traceroute results
  % traceroute www.google.com                                                                                                                                                                                                            !10002
traceroute to www.google.com (216.58.192.36), 64 hops max, 52 byte packets
 1  10.0.1.1 (10.0.1.1)  1.413 ms  0.838 ms  1.336 ms
 2  73.202.24.1 (73.202.24.1)  382.560 ms  363.112 ms  418.922 ms
 3  te-0-7-0-10-sur03.pleasanton.ca.sfba.comcast.net (68.85.217.65)  342.021 ms  154.543 ms  420.710 ms
 4  be-226-rar01.pinole.ca.sfba.comcast.net (162.151.78.209)  430.162 ms  441.550 ms  436.743 ms
 5  hu-0-2-0-0-ar01.santaclara.ca.sfba.comcast.net (68.85.154.41)  437.883 ms
    hu-0-1-0-1-ar01.santaclara.ca.sfba.comcast.net (68.85.154.37)  440.190 ms
    hu-0-1-0-3-ar01.santaclara.ca.sfba.comcast.net (68.85.154.45)  442.056 ms
slack://channel?id=<channel/group/user-id>&team=<team-id>
@skhavari
skhavari / updateCC.sh
Created August 27, 2014 04:04
Package CoreOS Cloud Config on Mac
mkdir -p ./config-2/openstack/latest
cp user_data ./config-2/openstack/latest/user_data
hdiutil makehybrid -o config.iso ./config-2 -iso -joliet
rm -rf ./config-2
@skhavari
skhavari / GitHubStars.sh
Last active October 26, 2021 14:44
Bash Script to Get Stars on GitHub Project
#!/bin/bash
# repo.txt has 1 entry per line like: docker/docker
for repo in $( cat repo.txt ); do
cmd="curl -s -I https://api.github.com/repos/$repo/stargazers\?page\=1\&per_page\=1 | grep "Link:" | sed -e 's@.*stargazers?page=@@' | sed -e 's@&per_page=1.*@@'"
stars=`$cmd`
echo $repo $stars
done
// HTTP forward proxy server that can also proxy HTTPS requests
// using the CONNECT method
// requires https://github.com/nodejitsu/node-http-proxy
var httpProxy = require('http-proxy'),
url = require('url'),
net = require('net'),
http = require('http');
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>URL</key>
<string>https://docs.google.com/a/your-domain/document/create?hl=en</string>
</dict>
</plist>
sudo dd if=/dev/rdisk1 of=/Users/skhavari/rasp.img bs=1m
sudo npm install -g forever