Skip to content

Instantly share code, notes, and snippets.

View Videmor's full-sized avatar

Jorge Crisóstomo Videmor

View GitHub Profile
@Videmor
Videmor / postgres-cheatsheet.md
Created May 3, 2018 01:54 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@Videmor
Videmor / tmux-cheatsheet.markdown
Created April 26, 2018 05:19 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault

##Steps

@Videmor
Videmor / find_frecuency.txt
Last active October 19, 2015 22:12
Ejercicios Ruby
Given a sentence containing multiple words, find the frequency of a given word in that sentence.
Construct a method named 'find_frequency' which accepts two arguments 'sentence' and 'word', both of which are String objects.
Example: The method, given 'Ruby is The best language in the World' and 'the', should return 2 (comparison should be case-insensitive).
Hint: You can use the method Array#count to count the frequency of any element in the given array. eg:
[9,3,4,9,5].count(9)
Will return the value 2
@Videmor
Videmor / gist:19091cbfe9ec7380f6d7
Created August 17, 2015 06:11
android PhoneStateListener
TextView text;
public String num = "num";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TelephonyManager TelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
TelephonyMgr.listen(new TeleListener(),
PhoneStateListener.LISTEN_CALL_STATE);
swifter.authorizeWithCallbackURL(
NSURL(string: "swifter://success"),
success: {
accessToken, response in
self.alert("Successfully authorized with App API")
self.fetchTwitterHomeStream(swifter)
},
failure: failureHandler
)
@Videmor
Videmor / my_map
Last active December 30, 2015 23:59
Demo mymap
class Array
def my_map
if block_given?
data = []
self.each { |el| data << yield(el) }
data
else
self.to_enum
end
@Videmor
Videmor / ruby warrior level 4
Last active December 30, 2015 21:09
Ruby Warrior - Level 4 : No new abilities this time, but you must be careful not to rest while taking damage. Save a @health instance variable and compare it on each turn to see if you're taking damage.
class Player
def play_turn(warrior)
# cool code goes here
@health = warrior.health unless @health
if warrior.feel.enemy?
warrior.attack!
elsif warrior.health < 8 or @health < warrior.health
warrior.rest!
#!/usr/bin/env bash
curl https://s3.amazonaws.com/heroku-jvm-buildpack-vi/vim-7.3.tar.gz --output vim.tar.gz
mkdir vim && tar xzvf vim.tar.gz -C vim
export PATH=$PATH:/app/vim/bin
#!/usr/bin/env bash
curl https://s3.amazonaws.com/heroku-jvm-buildpack-vi/vim-7.3.tar.gz --output vim.tar.gz
mkdir vim && tar xzvf vim.tar.gz -C vim
export PATH=$PATH:/app/vim/bin