Skip to content

Instantly share code, notes, and snippets.

View mloskot's full-sized avatar
🏠
Working from home

Mateusz Łoskot mloskot

🏠
Working from home
View GitHub Profile
@codesoda
codesoda / JsonBuilder.cs
Last active July 31, 2017 12:29
A Simple c# class for creating well formed JSON strings when serializing classes with Json.NET is overkill.
public class JsonBuilder
{
private readonly StringBuilder _sb;
private readonly Stack<bool> _hasPreviousProperties;
private bool RequiresComma { get { return _hasPreviousProperties.Count > 0 && _hasPreviousProperties.Peek(); } }
public JsonBuilder() {
_sb = new StringBuilder();
@trodrigues
trodrigues / gist:1023167
Created June 13, 2011 16:51
Checkout only certain branches with git-svn
If you want to clone an svn repository with git-svn but don't want it to push all the existing branches, here's what you should do.
* Clone with git-svn using the -T parameter to define your trunk path inside the svnrepo, at the same time instructing it to clone only the trunk:
git svn clone -T trunk http://example.com/PROJECT
* If instead of cloning trunk you just want to clone a certain branch, do the same thing but change the path given to -T:
git svn clone -T branches/somefeature http://example.com/PROJECT
@katta
katta / gitdiff-svnpatch.sh
Created June 16, 2011 08:10
Converts git diff to svn patch format
git diff --no-prefix | sed -e "s/^diff --git [^[:space:]]*/Index:/" -e "s/^index.*/===================================================================/" --ignore-space-at-eol > changes.patch
@tmcgilchrist
tmcgilchrist / gist:1103621
Created July 25, 2011 05:40
Rails 3 Setup for Oracle 10g XE

Notes on Setting up Oracle 10g XE with Rails

Capturing my notes about setting up an Oracle 10g XE / Rails environment for development work. Tested using the following versions, others may work as well:

  1. Ubuntu 11.04
  2. Ruby 1.9.2
  3. Rails 3
  4. Oracle 10 XE
@clintel
clintel / gist:1155906
Created August 19, 2011 02:40
Fenced code in bullet lists with GitHub-flavoured MarkDown??

Fenced code blocks inside ordered and unordered lists

  1. This is a numbered list.

  2. I'm going to include a fenced code block as part of this bullet:

    Code
    More Code
    
@bradland
bradland / ssh-known-hosts-mgmt.sh
Last active April 4, 2023 21:21
SSH known_hosts tools
# This is a short collection of tools that are useful for managing your
# known_hosts file. In this case, I'm using the '-f' flag to specify the
# global known_hosts file because I'll be adding many deploy users on this
# system. Simply omit the -f flag to operate on ~/.ssh/known_hosts
# Add entry for host
ssh-keyscan -H github.com >> /etc/ssh/ssh_known_hosts
# Scan known hosts
ssh-keygen -f /etc/ssh/ssh_known_hosts -F github.com
@indexzero
indexzero / readme-outline.md
Created November 14, 2011 08:26
A quick outline of a README.md

README.md Outline

  • Header and a Brief description (should match package.json)
  • Example (if applicable)
  • Motivation (if applicable)
  • API Documentation: This will likely vary considerably from library to library.
  • Installation
  • Tests
  • Contributors
  • License
@hellekin
hellekin / .zsh-prompt
Created November 28, 2011 19:43
not yet a promptinit theme, but pretty nice already
# -*- sh-mode -*-
#
## ZSH PROMPT
#
# {{{ PROMPT SETTINGS
PROMPT_SUBST=1 # Enable prompt expansion
PROMPT_BANG=1 # Enable ! as history event number
PROMPT_PERCENT=1 # Enable % parameter expansion
@brantfaircloth
brantfaircloth / cool_argparse_stuff.py
Created December 7, 2011 16:47
Some cool argparse stuff
class FullPaths(argparse.Action):
"""Expand user- and relative-paths"""
def __call__(self, parser, namespace, values, option_string=None):
setattr(namespace, self.dest, os.path.abspath(os.path.expanduser(values)))
def is_dir(dirname):
"""Checks if a path is an actual directory"""
if not os.path.isdir(dirname):
msg = "{0} is not a directory".format(dirname)
raise argparse.ArgumentTypeError(msg)
@dabrahams
dabrahams / constexpr_demo.cpp
Created December 11, 2011 01:29
Fun with C++11 constexpr
#include <iostream>
#include <iomanip>
//
// Utilities
//
// RETURNS() is used to avoid writing boilerplate "->decltype(x) { return x; }" phrases.
//
// USAGE: auto function(<arguments>) RETURNS(<some-expression>);
//