Skip to content

Instantly share code, notes, and snippets.

View akosma's full-sized avatar

Adrian Kosmaczewski akosma

View GitHub Profile
@esperlu
esperlu / mysql2sqlite.sh
Created April 27, 2011 05:46
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
@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>);
//
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@datagrok
datagrok / git-serve.md
Last active April 21, 2023 07:33
How to easily launch a temporary one-off git server from any local repository, to enable a peer-to-peer git workflow.
@anisoptera
anisoptera / NSDecimalNumberOperators.swift
Last active August 17, 2022 09:40
The overloads I've been dying to write since I started working with NSDecimalNumbers.
// The overloads I've been dying to write since I started working with NSDecimalNumbers.
import Foundation
@infix func > (left:NSDecimalNumber, right:NSDecimalNumber) -> Bool
{
return left.compare(right) == NSComparisonResult.OrderedDescending
}
@infix func < (left:NSDecimalNumber, right:NSDecimalNumber) -> Bool
@dwineman
dwineman / unscoped-method-calls
Last active January 8, 2016 12:02
Swift allows you to call instance methods from other instance methods with no scope prefix, indistinguishably from function calls. This leads to the dangerous situation of function calls being shadowed when identically-named instance methods are added to a base class.
// Derived class contains an instance method that calls a function foo() in its scope.
class Base {}
func foo() -> String {
return "function foo()"
}
class Derived: Base {
func bar() -> String {
@jpsim
jpsim / JAZMusician.h
Created July 7, 2014 09:25
SourceKit Playground
//
// JAZMusician.h
// JazzyApp
//
#import <Foundation/Foundation.h>
/**
JAZMusician models, you guessed it... Jazz Musicians!
From Ellington to Marsalis, this class has you covered.
@yosshy
yosshy / Dockerfile
Last active August 19, 2019 16:26
Dockerfile for Ubuntu 14.04 with upstart
FROM ubuntu:14.04
MAINTAINER Akira Yoshiyama <akirayoshiyama@gmail.com>
ENV DEBIAN_FRONTEND noninteractive
RUN mkdir -p /etc/apt /var/run
ADD sources.list /etc/apt/sources.list
RUN rm /etc/apt/sources.list.d/*
RUN apt-get update
RUN apt-get install --reinstall -y openssh-server python-apt upstart sysvinit-utils
RUN mv /sbin/initctl.distrib /sbin/initctl
@imjasonh
imjasonh / markdown.css
Last active May 24, 2024 22:56
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}