Skip to content

Instantly share code, notes, and snippets.

View madis's full-sized avatar
🧑‍💻
code mode

Madis Nõmme madis

🧑‍💻
code mode
View GitHub Profile
@madis
madis / bad_input.c
Created May 20, 2012 13:10
Secure programming homework
/**
* Secure programming HW4
* Find all potential vulnerabilities in this C function get_user_input
* Compiling: $ make main
* Running: $ ./main
*/
#include <stdio.h>
#include <stdlib.h> // For malloc
#include <string.h> // For strlen
@madis
madis / lets_install.sh
Created September 24, 2012 21:21
Lets install stuff automatically
#!/bin/bash
echo Doing it now!
@madis
madis / gist:3781480
Created September 25, 2012 12:26
Konkreetne vs Abstraktne
Konkreetne							|	Abstraktne
====================================================
roheline							- värv
Clojure								- programmeerimiskeel
minu iPhone, praegusel ajahetkel 	- lihtsalt telefon
Juku								- loll
Programmeerija firmas X				- töökoht
@madis
madis / check_dependencies.sh
Created September 25, 2012 19:22
Is RVM installed?
#!/bin/bash
echo "This script checks if you have all dependencies installed"
# Check for RVM
#RESULT= `type rvm | head -1`
RESULT="rvm is a function"
echo $RESULT
if [[ $RESULT = "rvm is a function" ]]; then
echo "RVM is OK"
@madis
madis / vim_findings.md
Created October 4, 2012 09:09
Vim findings

Line navigation

  • k - up
  • j - down
  • h - left
  • l - right

Current line, go to:

  • 0 - start
  • ^ - firs non-blank character
@madis
madis / gist:4067411
Last active October 12, 2015 18:18
Sublime tips
  • crtl+cmd+g - select matching text
  • crtl+m - jump to matching bracket
  • crtl+left/right - move cursor left / right word segment
  • crtl+k+d - discard current selection and create a cursor at the next
@madis
madis / gist:4101315
Created November 17, 2012 23:19
TextMate findings

Create ctags file for SublimeText containing current floder + used gemsets - ctags --extra=+f --exclude=.git --exclude=log -f .tags -R . `rvm gemdir`/gems/*

@madis
madis / gist:4126822
Created November 21, 2012 18:47
prompt with git additions
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;34m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
LIGHT_GRAY="\[\033[0;37m\]"
DARK_GRAY="\[\033[0;90m\]"
COLOR_NONE="\[\e[0m\]"
```bash
# Make a POST request with post parameter
# -i for showing headers
# -d for passing post parameters
curl -i -d "site_key=almost_random" -X POST http://localhost:3001/api/visits
# Save a cookie in a file
curl -c visits_cookie.txt -d "site_key=almost_random" -X POST http://localhost:3001/api/visits
# Make a POST request with cookie
@madis
madis / redis-server
Last active December 11, 2015 12:49
init.d script for starting redis server. Provides start/stop/reload/status
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog $remote_fs
# Required-Stop: $syslog $remote_fs
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db