Skip to content

Instantly share code, notes, and snippets.

View adamatan's full-sized avatar

Adam Matan adamatan

View GitHub Profile
@adamatan
adamatan / arduinoLedBinaryCount.c
Created July 27, 2012 13:28
Arduino: count from 0 to 255 in Led Binary
/* ---------------------------------------------------------
* | Arduino Experimentation Kit Example Code |
* | CIRC-02 .: 8 LED Fun :. (Multiple LEDs) |
* ---------------------------------------------------------
*
* A few Simple LED animations
*
* For more information on this circuit http://tinyurl.com/d2hrud
*
*/
@adamatan
adamatan / argparse_cut_paste.py
Created August 19, 2012 11:54
cut-paste-code::argparse
#!/usr/bin/python
import argparse
"""Boilerplate code for using argparse.
Clone, configure, and copy to your script.
Usage:
python argparse_cut_paste.py a 80 b c
@adamatan
adamatan / culmes-test.tex
Created August 24, 2012 21:58
Problems with modern CV template with Hebrew (Culmus + Babel)
%% LyX 1.5.4 created this file. For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[a4paper,english,hebrew]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9,cp1255]{inputenc}
\usepackage{babel}
\usepackage{culmus}
\begin{document}
@adamatan
adamatan / code_snippet.tex
Created August 26, 2012 10:49
Tex code snippet problem
% Glider, a hacker emblem (http://www.catb.org/hacker-emblem/)
% Author: Alex Hirzel
% License: Public Domain
\documentclass[border=1mm]{article}
\usepackage{tikz}
%%%<
\usepackage{verbatim}
\usepackage{listings}
\begin{document}
@adamatan
adamatan / gist:3754212
Created September 20, 2012 06:08
Stackoverflow.com langauge string
<!-- language: lang-java -->
<!-- language: lang-python -->
<!-- language: lang-sql -->
<!-- language: lang-bash -->
@adamatan
adamatan / time_difference.sh
Created September 20, 2012 06:14
Bash time difference
#!/bin/bash
# Based on http://www.cyberciti.biz/faq/shell-script-to-get-the-time-difference/
START=$(date +%s)
# Do something useful
END=$(date +%s)
DIFF=$(( $END - $START ))
echo "Finished in $DIFF seconds."
@adamatan
adamatan / CreateIndices.sql
Created September 23, 2012 09:49
MySQL: Create index if not exists
-- Creates an index if it does not already exist in MySQL.
-- Code by RolandoMySQLDBA, minor modifications by Adam Matan.
-- License: CC BY-SA, http://creativecommons.org/licenses/by-sa/3.0/
-- Source: http://dba.stackexchange.com/questions/24531/mysql-create-index-if-not-exists/24541#24541
DELIMITER $$
DROP PROCEDURE IF EXISTS `pixels`.`CreateIndex` $$
CREATE PROCEDURE `pixels`.`CreateIndex`
@adamatan
adamatan / .bashrc
Created September 24, 2012 19:29
Bash configurations
xset -dpms
alias star='ssh '
alias pass='ssh '
alias sair='sudo apt-get install'
alias srch='apt-cache search'
@adamatan
adamatan / python_cheat_sheet.tex
Created October 22, 2012 07:30
Python cheat sheet table problem
\documentclass[10pt,landscape]{article}
\usepackage{multicol}
\usepackage{tabularx}
\usepackage{calc}
\usepackage{ifthen}
\usepackage[landscape]{geometry}
\usepackage{verbatim}
\usepackage{graphicx}
\usepackage{color}
@adamatan
adamatan / subprocess_example.py
Created October 25, 2012 12:16
Python subprocess call
#!/usr/bin/python
import subprocess as sp
# Pipes used to prevent buffer problems with verbose output.
# stdout is redirected to stderr.
# shell=True allows spaces in 'cmd'.
# communicate() waits for termination and empties buffers into 'output'.
cmd = "ls"