Skip to content

Instantly share code, notes, and snippets.

We couldn’t find that file to show.
@padawin
padawin / git-svnbranch
Created October 16, 2013 10:06
script to checkout a branch in git from a svn repository, with git-svn. Usage: copy this file in your /usr/local/bin/ folder, and call git svnbranch <yourbranch> to checkout a branch. The local branch will be called local-<branchname>
#!/bin/sh
[ -z $1 ] && exit 1
git config --add svn-remote.$1.url svn+ssh://svnrepohost/path/to/branches/$1
git config --add svn-remote.$1.fetch :refs/remotes/$1
git svn fetch $1
git checkout -b local-$1 -t $1
git svn rebase $1
@padawin
padawin / trololo.c
Created October 22, 2013 11:46
Trololo c code A bit useless...
#include <stdio.h>
#define rololo printf(
#define trololololo void
#define trololo (
#define tro )
#define lolo {
#define trolo char
#define lo *
#define lololo =
#define t "trololo trololo trololo"
@padawin
padawin / float.html
Last active August 29, 2015 13:56
Float
<html>
<head>
<style type="text/css">
#mydiv {
position: absolute;
top: 200px;
left: 200px;
width: 50px;
height: 50px;
border: 1px black solid;
We couldn’t find that file to show.
We couldn’t find that file to show.
@padawin
padawin / README.md
Last active August 29, 2015 14:02
Get a 1-dimension array of random elements from a 2-dimensions array

Get a 1-dimension array of random elements from a 2-dimensions array - JAVASCRIPT

Use:

var a = [[1,2,3],[4,5,6],[7,8,9]];
console.log(random(a, 4));

displays:

# -*- coding: utf-8 -*-
import Image
def resize_and_crop(img_path, modified_path, size, crop_type='top'):
"""
Resize and crop an image to fit the specified size.
args:
img_path: path for the image to resize.
@padawin
padawin / deck.php
Last active August 29, 2015 14:04
Missing cards in deck
<?php
function findMissingCards($deck)
{
// The order is not the actual order of the cards in the deck, but the alpha order
// because I didn't implement the sort method here, but used a native one
$colors = array('C', 'P', 'Q', 'T');
$values = array(2, 3, 4, 5, 6, 7, 8, 9, 10, 'V', 'D', 'R', 'A');
$missingCards = array();
@padawin
padawin / git-base.sh
Last active August 29, 2015 14:11
migrate svn branch to git
#!/bin/sh
BRANCH=$1
TARGET=$2
BRANCH_FIRST_COMMIT=$3
# Checks
[ ! -d .git ] && echo "You must be in a git project" 1>&2 && exit 1
[ -z "$BRANCH" ] && echo "A branch is needed" 1>&2 && exit 1
[ -z "$TARGET" ] && echo "A target is needed" 1>&2 && exit 1