Skip to content

Instantly share code, notes, and snippets.

@thomet
thomet / string_diff.zsh
Created January 15, 2016 11:03
Color diff of two strings in zsh
function sdiff() {
wdiff <(echo "$1") <(echo "$2") | colordiff
}
@jatinganhotra
jatinganhotra / sparklistener-checkpointing.scala
Created November 9, 2015 00:38
SparkListener - Checkpointing jobs
import scala.collection.JavaConversions._ // for propertiesAsScalaMap function
sc.addSparkListener(new SparkListener() {
override def onJobStart(jobStart: SparkListenerJobStart) {
println("ADAPT: INSIDE Job Start Listener ");
var props = propertiesAsScalaMap(jobStart.properties)
if (props.contains("spark.rdd.scope"))
{
val propsMap = // Convert props to propsMap
if ( propsMap.contains("name") && propsMap("name") == "checkpoint")
@wpscholar
wpscholar / vagrant-cheat-sheet.md
Last active May 7, 2024 11:05
Vagrant Cheat Sheet

Typing vagrant from the command line will display a list of all available commands.

Be sure that you are in the same directory as the Vagrantfile when running these commands!

Creating a VM

  • vagrant init -- Initialize Vagrant with a Vagrantfile and ./.vagrant directory, using no specified base image. Before you can do vagrant up, you'll need to specify a base image in the Vagrantfile.
  • vagrant init <boxpath> -- Initialize Vagrant with a specific box. To find a box, go to the public Vagrant box catalog. When you find one you like, just replace it's name with boxpath. For example, vagrant init ubuntu/trusty64.

Starting a VM

  • vagrant up -- starts vagrant environment (also provisions only on the FIRST vagrant up)
@tsiege
tsiege / The Technical Interview Cheat Sheet.md
Last active May 9, 2024 13:54
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!






\

@aras-p
aras-p / preprocessor_fun.h
Last active May 8, 2024 06:45
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@naiquevin
naiquevin / thankyou.py
Last active September 16, 2020 16:09
Python script to thank people who sent birthday wishes on facebook
import sys
from urllib import urlencode
import requests
from urlparse import urlparse, parse_qs
from random import choice
import re
self_id = None # your facebook id here
utc_bday = None # utc timestamp of your birthday
@parksilk
parksilk / array_mode.rb
Last active June 20, 2018 20:52
Exercise: Calculating the array mode: Write a method "mode" which takes an Array of numbers as its input and returns an Array of the most frequent values. If there's only one most-frequent value, it returns a single-element Array. For example, mode([1,2,3,3]) # => [3] mode([4.5, 0, 0]) # => [0] mode([1.5, -1, 1, 1.5]) # => [1.5] mode([1,1,2,2]) …
def mode(array)
counter = Hash.new(0)
# this creates a new, empty hash with no keys, but makes all defalt values zero. it will be used to store
# the information from the array, such that the keys will be each unique number from the array (IOW, if there
# are two or more 4's in the array, there will just be one key that is a 4), and the value for each key will
# be the number of times that integer appears in the array.
array.each do |i|
counter[i] += 1
end
# this interates throught the array, and for each element it creates a key for that integer (if it hasn't been
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 10, 2024 16:49
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname