Skip to content

Instantly share code, notes, and snippets.

View dgk's full-sized avatar
🇬🇪

Dmitry Kuksinsky dgk

🇬🇪
View GitHub Profile
@katylava
katylava / git-selective-merge.md
Last active February 27, 2024 10:18
git selective merge

Update 2022: git checkout -p <other-branch> is basically a shortcut for all this.

FYI This was written in 2010, though I guess people still find it useful at least as of 2021. I haven't had to do it ever again, so if it goes out of date I probably won't know.

Example: You have a branch refactor that is quite different from master. You can't merge all of the commits, or even every hunk in any single commit or master will break, but you have made a lot of improvements there that you would like to bring over to master.

Note: This will not preserve the original change authors. Only use if necessary, or if you don't mind losing that information, or if you are only merging your own work.

@sumeet
sumeet / stopwatch.py
Created August 3, 2011 21:48
A Python timer class.
import time
class Stopwatch(object):
"""A stopwatch utility for timing execution that can be used as a regular
object or as a context manager.
NOTE: This should not be used an accurate benchmark of Python code, but a
way to check how much time has elapsed between actions. And this does not
account for changes or blips in the system clock.
@openback
openback / iso2wbfs
Created August 11, 2011 02:08
Uses Wiimms ISO Tool to convert one or more Wii ISO into a WBFS file, properly named for use on non-WBFS partitions
#!/bin/bash
#===============================================================================
#
# FILE: iso2wbfs
#
# USAGE: ./iso2wbfs [option] FILE... [wbfs directory]
#
# DESCRIPTION: Uses wit to convert one or more Wii ISO into a WBFS file
# properly named for use on non-WBFS partitions.
#
@gboeer
gboeer / gist:1231475
Created September 21, 2011 07:33
C++ String Tokenizer
#include <string>
#include <vector>
//! Tokenize the given string str with given delimiter. If no delimiter is given whitespace is used.
void Tokenize(const std::string& str, std::vector<std::string>& tokens, const std::string& delimiters = " ")
{
tokens.clear();
// Skip delimiters at beginning.
std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
// Find first "non-delimiter".
@dgk
dgk / pylife.py
Created December 26, 2011 11:36
Artificial life simulator
#!/usr/bin/env python
'''
usage: ./pylife.py
or ./pylife.py test
requirements:
PyBrain==0.3
numpy==1.6.1
scipy==0.10.0
'''
@chluehr
chluehr / date_loop.sh
Created April 26, 2012 20:28
Bash: Loop over dates
#!/bin/bash
now=`date +"%Y-%m-%d" -d "05/06/2012"`
end=`date +"%Y-%m-%d" -d "05/23/2012"`
while [ "$now" != "$end" ] ;
do
now=`date +"%Y-%m-%d" -d "$now + 1 day"`;
echo $now
done
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active June 21, 2024 01:45
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@mjallday
mjallday / redisbuffer.py
Created October 31, 2012 17:06
Redis Circular Buffer
class RedisCircularBuffer(object):
def __init__(self, namespace, size):
self.namespace = namespace
self.size = size
import redis
self.redis = redis.Redis()
def append(self, item):
self.redis.lpush(self.namespace, item)
@dgk
dgk / weeding.py
Created November 14, 2012 08:53
Backups weeding script
#!/usr/bin/python
# -*- coding: utf8 -*-
import os
import re
import datetime
from calendar import Calendar
from itertools import chain
KEEP_DAY = 0
@4ndrej
4ndrej / SSLPoke.java
Last active January 3, 2024 09:50
Test of java SSL / keystore / cert setup. Check the comment #1 for howto.
import javax.net.ssl.SSLParameters;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import java.io.*;
/** Establish a SSL connection to a host and port, writes a byte and
* prints the response. See
* http://confluence.atlassian.com/display/JIRA/Connecting+to+SSL+services
*/
public class SSLPoke {