Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
https://bergpb.github.io

Berg Paulo bergpb

💻
https://bergpb.github.io
View GitHub Profile
@kstroud1
kstroud1 / sources.list
Created Nov 17, 2014
sources.list for 13.04
View sources.list
# deb cdrom:[Ubuntu 13.04 _Raring Ringtail_ - Release amd64 (20130424)]/ raring main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://old-releases.ubuntu.com/ubuntu/ raring main restricted
deb-src http://old-releases.ubuntu.com/ubuntu/ raring main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://old-releases.ubuntu.com/ubuntu/ raring-updates main restricted
@sarahhodne
sarahhodne / gist:1341827
Created Nov 5, 2011
Use pry for rails console
View gist:1341827
# Launch Pry with access to the entire Rails stack.
# If you have Pry in your Gemfile, you can pass: ./script/console --irb=pry
# instead. If you don't, you can load it through the lines below :)
rails = File.join(Dir.getwd, 'config', 'environment.rb')
if File.exist?(rails) && ENV['SKIP_RAILS'].nil?
require rails
if Rails.version[0..0] == '2'
require 'console_app'
@cuth
cuth / serve.js
Created Apr 14, 2014
Run a local express server on the current directory's static files using node
View serve.js
var host = "127.0.0.1";
var port = 1337;
var express = require("express");
var app = express();
app.use('/', express.static(__dirname + '/'));
app.listen(port, host);
console.log('Running server at http://localhost:' + port + '/');
@michalc
michalc / table_csv_view.py
Created Mar 7, 2019
Django + gevent + psycopg2 download whole PostgreSQL table as CSV
View table_csv_view.py
import csv
import logging
import gevent
from psycopg2 import (
connect,
sql,
)
from django.conf import (
View .pryrc
# === EDITOR ===
Pry.editor = 'vim'
# == Pry-Nav - Using pry as a debugger ==
Pry.commands.alias_command 'c', 'continue' rescue nil
Pry.commands.alias_command 's', 'step' rescue nil
Pry.commands.alias_command 'n', 'next' rescue nil
Pry.commands.alias_command 'r!', 'reload!' rescue nil
Pry.config.color = true
@Levantado
Levantado / custom_validators.py
Last active Sep 9, 2019
Flask WTF custom validator
View custom_validators.py
from wtforms.validators import ValidationError
class UniqChecker:
def __init__(self, model, fieldname, message=None):
if message:
self.message = message
else:
self.message = "You shall no pass"
self.model = model
@zspecza
zspecza / amok_browserify_gulpfile.js
Last active Sep 29, 2019
Live inject CSS, Javascript & HTML with BrowserSync, Watchify, Amok & Gulp (excuse the messiness, still a WIP)
View amok_browserify_gulpfile.js
/*=====================================*\
build tasks
\*=====================================*/
/**
* This gulpfile is optimised for developing
* React.js apps in ES6 through Babel, and is
* designed to live-inject CSS, HTML and even JavaScript
* changes so maintaining state in an application when
* editing code is super easy.
View fix-npm-permissions.md

##Fixing npm permissions

You may receive an EACCES error when you try to install a package globally. This indicates that you do not have permission to write to the directories that npm uses to store global packages and commands.

You can fix this problem using one of three options:

Change the permission to npm's default directory. Change npm's default directory to another directory. Install Node with a package manager that takes care of this for you. You should back-up your computer before moving forward.

@daltonjorge
daltonjorge / rails_annotations.md
Created Aug 8, 2012 — forked from hakagura/rails_annotations.md
Explicações de conceitos do Rails e outras infos úteis.
View rails_annotations.md

Active Record

É um design pattern que o Rails implementa a partir da gem ActiveRecord.

Serve para conectar a camada Model da aplicação com tabelas do database, para assim criar um modelo de domínio persistível, onde a lógica (Model) e dados (BD) são apresentados em uma única solução.

Já persiste no BD:

obj.create
@runemadsen
runemadsen / app.rb
Created Oct 17, 2012
Sinatra File Upload
View app.rb
require 'sinatra'
get "/" do
erb :form
end
post '/save_image' do
@filename = params[:file][:filename]
file = params[:file][:tempfile]