Skip to content

Instantly share code, notes, and snippets.

@pulcheri
pulcheri / main.cpp
Created February 8, 2016 20:48 — forked from Jiwan/main.cpp
Final C++14 example for my post - An introduction to C++'s variadic templates: a thread-safe multi-type map
#include <iostream>
#include <memory>
#include <string>
#include "repository.hpp"
// Incomplete types used as compile-time keys.
struct Key1;
struct Key2;
@pulcheri
pulcheri / howto
Last active August 29, 2015 14:27 — forked from coopernurse/howto
the world's dumbest Haskell json-rpc example
cabal install scotty
cabal install aeson
runhaskell server.hs
curl -X POST -d '{"jsonrpc":"2.0", "method":"Calc.Add", "params":[10,50], "id":"abc"}' http://localhost:3000/api
// solution for https://www.hackerrank.com/challenges/even-tree
#include <iostream>
#include <fstream>
#include <map>
#include <deque>
#include <vector>
#include <cstring>
#include <algorithm>
import os
import argparse
import os.path
import shutil
from PIL import Image
from glob import glob
# http://stackoverflow.com/questions/9166400/convert-rgba-png-to-rgb-with-pil
#def pure_pil_alpha_to_color_v2(image, color=(255, 255, 255)):

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results

How do I get an apk file from an Android device?

http://stackoverflow.com/questions/4032960/how-do-i-get-an-apk-file-from-an-android-device

None of these suggestions worked for me, because Android was appending a sequence number to the package name to produce the final APK file name (this may vary with the version of Android OS). The following sequence of commands is what worked for me on a non-rooted device:

  1. Determine the package name of the app, e.g. "com.example.someapp". Skip this step if you already know the package name.

adb shell pm list packages Look through the list of package names and try to find a match between the app in question and the package name. This is usually easy, but note that the package name can be completely unrelated to the app name. If you can't recognize the app from the list of package names, try finding the app in Google Play using a browser. The URL for an app in Google Play contains the package name.

'''
Texture atlas generator / Kalio.net
klibs commit: 709551bcf617976a19e6105165eda9524007fc08
Copyright 2012 Kalio Ltda.
http://blog.kalio.net/post/31067884387/yet-another-texture-atlas-packer
Requirements:
- PIL: http://www.pythonware.com/products/pil/
#!/bin/bash
#script extraido de: http://paulocassiano.wordpress.com/2008/08/29/deixando-o-gedit-com-a-cara-do-textmate/
#tip for better "resolution" here: http://blog.siverti.com.br/2008/05/22/fonte-monaco-no-ubuntugedit/
cd /usr/share/fonts/truetype/
#TODO: put validation if folder already exists
sudo mkdir ttf-monaco
#!/bin/sh
USAGE="Usage: $0 processName"
if [ $# -ne 1 ]; then
echo $USAGE
exit 1
fi
@pulcheri
pulcheri / gist:4559121
Last active December 11, 2015 06:28
git create/push/delete branch

How do I revert one file to the last commit in git?

git checkout -- filename You can do it without the -- (as suggested by nimrodm), but if the filename looks like a branch or tag (or other revision identifier), it may get confused, so using -- is best.

You can also check out a particular version of a file:

git checkout v1.2.3 -- filename # tag v1.2.3

git checkout stable -- filename # stable branch