Skip to content

Instantly share code, notes, and snippets.

@johnnyeric
johnnyeric / gist:3753909
Created September 20, 2012 04:01 — forked from thehydroimpulse/gist:2872907
A Laravel task generator. Models, Migrations and Controllers.
<?php
/**
* @copyright 2012 TheHydroImpulse, Daniel Fagnan
* @version 0.1
* @todo Add an overwite ability. Among other things.
* @note Use this as you wish. Extend it, Mash it. Enjoy it.
*/
@johnnyeric
johnnyeric / gist:4722324
Last active December 12, 2015 05:29
Ruby on Rails helper methods for creating social buttons at the view
#Gets the url, the width and height like integer.
def facebook_button(url,width,height)
"<iframe src=\"http://www.facebook.com/plugins/like.php?href=#{url}&;layout=standard&<br>
show_faces=false&width=380&action=like&colorscheme=light&height=#{width}&locale=pt_BR\" scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:#{width}px; height:#{height}px;\" allowTransparency=\"true\"></iframe>".html_safe
end
#gets the actual url
def twitter_button
"<a href=\"https://twitter.com/share\" class=\"twitter-share-button\" data-lang=\"pt\">Tweetar</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=\"//platform.twitter.com/widgets.js\";fjs.parentNode.insertBefore(js,fjs);}}(document,\"script\",\"twitter-wjs\");</script>".html_safe
$ cd ~/Downloads/redis-2.4.14
$ make test
$ make
@johnnyeric
johnnyeric / AndroidBitmapFromView
Created June 15, 2015 02:52
Android - This method extracts the bitmap from an Android view
public static Bitmap loadBitmapFromView(View view) {
Bitmap bitmap = Bitmap.createBitmap( view.getMeasuredWidth(), view.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
view.draw(canvas);
return bitmap;
}
@johnnyeric
johnnyeric / gist:dd9984e4439b71393f48eb4ae292b842
Created April 11, 2016 00:23 — forked from neumino/gist:6554108
Filtering nested arrays with RethinkDB
r.table("test").filter( function(doc) {
return doc("adresses").contains(function(adress) {
return adress("city").eq("Paris")
})
})
/*
{
@johnnyeric
johnnyeric / readline-test.js
Created May 15, 2016 17:29 — forked from SBoudrias/readline-test.js
Node.js Readline and CLI keypress example
var readline = require('readline'),
_ = require('lodash'),
charm = require('charm')(process.stdout),
rl = readline.createInterface(process.stdin, process.stdout);
var selected = 0;
var choices = [
"foo",
"bar",
"javascript",
@johnnyeric
johnnyeric / Analyse.java
Created May 30, 2016 12:31 — forked from leomelzer/Analyse.java
Simple-stupid Sentiment analysis for 1 million tweets.
package analyse;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@johnnyeric
johnnyeric / Watcher.java
Created June 16, 2016 20:08 — forked from taichi/Watcher.java
example of java.nio.file.WatchService
package sandbox;
import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE;
import static java.nio.file.StandardWatchEventKinds.ENTRY_DELETE;
import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY;
import java.io.IOException;
import java.nio.file.ClosedWatchServiceException;
import java.nio.file.FileSystem;
@johnnyeric
johnnyeric / introrx.md
Created June 26, 2016 18:39 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@johnnyeric
johnnyeric / dokku_on_digital_ocean.md
Created July 12, 2016 19:56 — forked from henrik/dokku_on_digital_ocean.md
Notes from running Dokku on Digital Ocean.

My notes for Dokku on Digital Ocean.

Commands

Install dokku-cli (gem install dokku-cli) for a more Heroku-like CLI experience (dokku config:set FOO=bar).

# List/run commands when not on Dokku server (assuming a "henroku" ~/.ssh/config alias)
ssh henroku dokku
ssh henroku dokku config:get my-app