Skip to content

Instantly share code, notes, and snippets.

View cirocosta's full-sized avatar

Ciro S. Costa cirocosta

View GitHub Profile
@cirocosta
cirocosta / split_string.c
Last active August 28, 2015 15:42
Splits a string into char** given a delimiter
char** ep1sh_split_string(const char* input, unsigned* size,
const char delimiter)
{
size_t input_size = strlen(input);
unsigned count = 0;
unsigned i = 0;
char** result = NULL;
char* tmp = strndup(input, input_size);
char* tmp_init = tmp;
@cirocosta
cirocosta / running-epd-tests.md
Created February 14, 2014 17:08
Running endpoints-proto-datastore tests

A quick way for running endpoints-proto-datastore tests

  • download App Engine SDK to the root of the project.
  • create a virtualenv and then add the root of App Engine SDK to it
$ virtualenv .env
$ echo "$(pwd)/google_appengine" > .env/lib/python2.7/site-packages/gae.pth
@cirocosta
cirocosta / creating-user-mysql.md
Last active August 29, 2015 13:56
Creating a user with Mysql CLI

quick snippet for creating a user w/ mysql cli.

First, login and create a user:

$ mysql -u root_user -p
mysql > CREATE USER 'username'@'place' IDENTIFIED BY 'password';

then, grant privileges to it. The syntax is as follows:

@cirocosta
cirocosta / get_inet_addr.sh
Last active August 29, 2015 13:56
Gets the INET address
WIFIIP=$(ip addr | awk '/inet/ && /wlan0/{sub(/\/.*$/,"",$2); print $2}')
echo $(WIFIIP)
@cirocosta
cirocosta / all-occurences.sh
Last active August 29, 2015 13:57
Outputs the line of the first occurence of a pattern with grep
$ grep -n --exclude-dir="node_modules" 'term to be searched for' -r # searches recursively for a term and outputs with line number
@cirocosta
cirocosta / git-diff.md
Created March 25, 2014 11:41
diffing with git

What changes i've made to the files which i didn't stage yet?

$ git diff

How does my staged files differs from the most recent commit?

$ git diff --staged
@cirocosta
cirocosta / force_res.sh
Created March 25, 2014 16:33
Forcing resolution mint
#!/bin/bash
# After following the tutorial, this will be the commands generated.
# Don't just copy and paste these values.
xrandr --newmode "1440x900_60.00" 106.50 1440 1528 1672 1904 900 903 909 934 -hsync +vsync
xrandr --addmode VGA1 "1440x900_60.00"
# source: http://community.linuxmint.com/tutorial/view/877
@cirocosta
cirocosta / piping_to_clipboard.sh
Created March 26, 2014 18:08
Piping to the Clipboard
sudo apt-get install xsel
echo "sample text" | xsel -i -b
@cirocosta
cirocosta / ss-area.md
Last active August 29, 2015 13:57
How to take a screenshot of a particular region w/ Linux

From this great answer:

For the whole screen

$ import -window root path/to/output.png

For a selected window

$ WINDOW=$(xdpyinfo | grep focus) && import -window $WINDOW /path/to/output.png
@cirocosta
cirocosta / togetherjs-parallax.js
Created April 22, 2014 00:28
A simple parallax from the source of together js.
// THE FOLLOWING CODE IS NOT MINE, WILL DO SOMETHING WITH IT LATER. CREDITS TO TOGETHERJS
$(document).ready(function(){
// detect a mobile device
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {