Skip to content

Instantly share code, notes, and snippets.

View roolebo's full-sized avatar

Roman Bolshakov roolebo

View GitHub Profile
@flashvoid
flashvoid / gist:7bcc7c7813114e1bd238
Last active October 14, 2015 17:27
linux network namespace routing
ip netns add space-a
ip netns add space-b
ip link add veth0 type veth peer name veth1
ip link set veth1 netns space-a
ip link add veth2 type veth peer name veth3
ip link set veth3 netns space-b
ifconfig veth0 0.0.0.0 up
ifconfig veth2 0.0.0.0 up
ip netns exec space-a ifconfig veth1 192.168.1.130/32 up
ip netns exec space-a route add -host 192.168.7.141 dev veth1
@karrick
karrick / flock.go
Last active November 12, 2020 18:03
Examples of using advisory locking with golang.org/x/sys/unix
// These funcitons ought to come with a huge warning. Using them without
// understanding the differences between blocking and non-blocking, or
// between exclusive and shared access, and when to use them will cause
// problems that do not necessarily manifest right away, but rather
// fester in your program and rear their ugly head in the middle of the
// night when you're sleeping.
//
// If you use advisory file locking, *always* use Shared locking every
// single time you read the file, and *always* use Exclusive locking every
// single time you write the file. Period. There are no exceptions. Heed
@logost
logost / iscsi_abort.py
Created April 7, 2021 12:28
Send ABORT over iSCSI
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
# Author : tintinweb@oststrom.com <github.com/tintinweb>
'''
A simple TCP three-way handshake example
#> python scapy_tcp_handshake.py
DEBUG:__main__:init: ('oststrom.com', 80)
DEBUG:__main__:start
DEBUG:__main__:SND: SYN
@phillbaker
phillbaker / lmu.m
Created November 17, 2012 20:23
Macbook ambient light sensor data
// Compile with $ gcc -o lmutracker lmu.m -framework IOKit -framework CoreFoundation -framework Foundation
// Usage: ./lmu [now]
// Prints out the value from the ambient light sensor and the back light LED every 1/10 of a second. Optionally print just one value.
// Inspired by the code found at
// http://google-mac-qtz-patches.googlecode.com/svn-history/r5/trunk/AmbientLightSensor
// and http://osxbook.com/book/bonus/chapter10/light/
// and http://en.wikipedia.org/wiki/Wikipedia:Reference_desk/Archives/Computing/2010_February_10#Mac_OS_X_keyboard_backlight_drivers
// http://forums.macrumors.com/showthread.php?t=1133446
#include <stdio.h>
@marc-rutkowski
marc-rutkowski / README.md
Last active June 17, 2021 13:17
react-storybook with react-boilerplate (content of the .storybook/ directory)

react-storybook with react-boilerplate

Explains how to install and configure react-storybook into a project created from the react-boilerplate setup.

Intro

React-boilerplate (rbp) is a good starting point to create React apps, with a focus on performance, best practices and DX.

The community around the repository is amazing and a constant source of learning.

@ashw7n
ashw7n / ovsdb.py
Last active August 26, 2021 16:40
ovsdb-python-client
import collections
import threading
__author__ = 'ashw7n'
import socket
import json
import logging
logging.basicConfig(level=logging.DEBUG)
@kristopherjohnson
kristopherjohnson / partial.swift
Last active March 3, 2022 16:11
Experiments with partial function application in Swift
func partial<A, B, T>(f: (A, B) -> T, a: A) -> (B) -> T {
return { f(a, $0) }
}
func bind2nd<A, B, T>(f: (A, B) -> T, b: B) -> (A) -> T {
return { f($0, b) }
}
func partial<A, B, C, T>(f: (A, B, C) -> T, a: A) -> (B, C) -> T {
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
void print_prot_bits(int prot) {
printf((prot & PROT_READ) == 0 ? "-" : "R");
printf((prot & PROT_WRITE) == 0 ? "-" : "W");
printf((prot & PROT_EXEC) == 0 ? "-" : "X");
}
@traviskaufman
traviskaufman / jasmine-this-vars.md
Last active September 19, 2022 14:35
Better Jasmine Tests With `this`

Better Jasmine Tests With this

On the Refinery29 Mobile Web Team, codenamed "Bicycle", all of our unit tests are written using Jasmine, an awesome BDD library written by Pivotal Labs. We recently switched how we set up data for tests from declaring and assigning to closures, to assigning properties to each test case's this object, and we've seen some awesome benefits from doing such.

The old way

Up until recently, a typical unit test for us looked something like this:

describe('views.Card', function() {