Skip to content

Instantly share code, notes, and snippets.

View mortymacs's full-sized avatar

Morteza NourelahiAlamdari mortymacs

View GitHub Profile
@ijt
ijt / http_get.go
Last active August 23, 2021 12:37
Example of using http.Get in go (golang)
package main
import (
"fmt"
"io"
"log"
"net/http"
"os"
)
@cournape
cournape / gist:1077528
Created July 12, 2011 07:00
cython c++ example
# rectangle.pyx
cdef extern from "Rectangle.h" namespace "shapes":
cdef cppclass Rectangle:
Rectangle(int, int, int, int)
int x0, y0, x1, y1
int getLength()
int getHeight()
int getArea()
void move(int, int)
@pazdera
pazdera / gist:1098119
Created July 21, 2011 20:25
Singleton example in C++
/*
* Example of a singleton design pattern.
* Copyright (C) 2011 Radek Pazdera
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
@spicycode
spicycode / tmux.conf
Created September 20, 2011 16:43
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
@codeeval
codeeval / sample.py
Created October 3, 2011 02:13
Sample code to read in test cases
# On CodeEval, test cases are read in from a file which is the first argument to your program
# Open the file and read in line by line. Each line represents a different test case
# (unless given different instructions in the challenge description)
import sys
test_cases = open(sys.argv[1], 'r')
for test in test_cases:
# ignore test if it is an empty line
@3demax
3demax / tabbar-tweak.el
Created October 5, 2011 14:58
Emacs tabbar-mode visual tweaks
;; This are setting for nice tabbar items
;; to have an idea of what it looks like http://imgur.com/b0SNN
;; inspired by Amit Patel screenshot http://www.emacswiki.org/pics/static/NyanModeWithCustomBackground.png
;; Tabbar
(require 'tabbar)
;; Tabbar settings
(set-face-attribute
'tabbar-default nil
:background "gray20"
@chrisguitarguy
chrisguitarguy / server.py
Created October 24, 2011 03:14
Super simple python socket server and HTTP request class.
import socket, traceback
HOST = ''
PORT = 51235
CLRF = '\r\n'
class InvalidRequest(Exception):
pass
class Request(object):
@tonious
tonious / hash.c
Last active June 21, 2024 00:57
A quick hashtable implementation in c.
/* Read this comment first: https://gist.github.com/tonious/1377667#gistcomment-2277101
* 2017-12-05
*
* -- T.
*/
#define _XOPEN_SOURCE 500 /* Enable certain library functions (strdup) on linux. See feature_test_macros(7) */
#include <stdlib.h>
#include <stdio.h>
@shadowbrain
shadowbrain / parse json with sed
Created December 16, 2011 15:32
parse json key:value with sed
## Example: Grab the value for the MYSQL_USER key
User=$( sed -n 's/.*"MYSQL_USER": "\(.*\)",/\1/p' /var/lib/credentials.json )
## Example: Grab the value for the MYSQL_PASSWORD key
Passwd=$( sed -n 's/.*"MYSQL_PASSWORD": "\(.*\)",/\1/p' /var/lib/credentials.json )

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: