Skip to content

Instantly share code, notes, and snippets.

View aalvarado's full-sized avatar
😎

Adan Alvarado aalvarado

😎
View GitHub Profile
Person = {
instance: function(name, lastname)
{
var base = this;
base._private = {}
base._public = {}
base._private.name = name;
base._private.lastname = lastname;
@aalvarado
aalvarado / changeLineRecorded.py
Created October 27, 2010 23:50
Snippet from my record line file for pythonscript plugin in n++
class FilePosition:
def __init__(self, bufferId):
self.bufferId = bufferId #sets the bufferId
self.filePositions = [] # where the modified lines will be stored
self.lastPos = 0
self.counter = 0
def addFilePosition(self, pos):
self._findDelete(pos) # checks if the line number is already in the list
@mcmire
mcmire / table_helpers.rb
Last active December 18, 2015 23:19
Helper for use in RSpec/Capybara feature tests to find a table on a page and convert it into an array of arrays, so that you can make an assertion on it. Similar to Cucumber's #tableize but is better about stringifying cell content.
module TableHelpers
VALID_FORMATS = [:html, :text]
# Find a table on the page and convert it to an array of arrays.
#
# selector_or_node - A String CSS selector to find the table, or a
# Nokogiri::XML::Node object (if you already have a
# reference to the table).
# options - Optional hash:
# columns - An Integer or Range of Integers. Lets you
@emilyst
emilyst / .vimrc
Last active July 24, 2016 17:45
I'm trying to keep this up to date with whatever my actual .vimrc is at the time. It may or may not track pretty closely, but at the time of writing this description (1 Mar 14), it's perfectly up to date.
" 0 preamble ============================================================== {{{
"
" There is a great organization scheme in place here. If you run the
" :options command in Vim, you see a list of all the options that you
" can set, along with their current settings and a brief description of
" them. The great thing about this scheme is that--for better or
" worse--it sets up a system which can organize all my settings. I've
" decided to organize everything below thus, throwing ancillary things
" (my own mappings, plugin settings, and so on) where it makes sense.
"
@ArthurN
ArthurN / i18n.rb
Created December 2, 2013 01:07
Monkey-patch Rails I18n.translate to see what keys ActiveModel is trying to use.
#initializers/i18n.rb
I18n.module_eval do
class << self
def translate_with_puts(*args)
Rails.logger.debug "#{args}"
old_translate(*args)
end
alias :old_translate :translate
alias :translate :translate_with_puts
end
@aalvarado
aalvarado / _Algorithms_
Last active August 22, 2018 16:48
Algorithms
1
@dideler
dideler / upgrade-postgres-9.3-to-9.4.md
Last active June 8, 2020 03:24
Upgrading PostgreSQL from 9.3 to 9.4 when upgrading Ubuntu 14.04 to 14.10

TL;DR

Create a backup:

pg_dumpall > mybackup.sql

Perform the upgrade:

sudo pg_dropcluster 9.4 main --stop
@maxivak
maxivak / send_data-send_file-remote-images-download
Created January 1, 2013 23:34
Rails. Download remote image as attachment in browser
# in controller
# for local files
send_file '/path/to/file', :type => 'image/jpeg', :disposition => 'attachment'
# for remote files
require 'open-uri'
url = 'http://someserver.com/path/../filename.jpg'
data = open(url).read
send_data data, :disposition => 'attachment', :filename=>"photo.jpg"
@leotm
leotm / findAndReplace.js
Last active March 22, 2022 13:37
Node.js - Find and Replace file(s)
var glob = require('glob');
var fs = require('fs');
var replace = require('replace');
// Find file(s)
glob('fileName.txt', function(err, files) {
if (err) { throw err; }
files.forEach(function(item, index, array) {
console.log(item + ' found');
@nuxlli
nuxlli / console.rb
Created July 10, 2012 17:43
To access url helpers (url_for, etc) from Rails console (Rails 3)
# Example from: http://snipplr.com/view/37063/
include Rails.application.routes.url_helpers
# set host in default_url_options:
default_url_options[:host] = "localhost"
# can then use:
url_for()