Skip to content

Instantly share code, notes, and snippets.

View bergpb's full-sized avatar
💻
https://blog.bergpb.dev

Lindemberg Barbosa bergpb

💻
https://blog.bergpb.dev
View GitHub Profile
@kstroud1
kstroud1 / sources.list
Created November 17, 2014 09:47
sources.list for 13.04
# 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 November 5, 2011 18:01
Use pry for rails console
# 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 April 14, 2014 17:21
Run a local express server on the current directory's static files using node
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 March 7, 2019 09:19
Django + gevent + psycopg2 download whole PostgreSQL table as CSV
import csv
import logging
import gevent
from psycopg2 import (
connect,
sql,
)
from django.conf import (
# === 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 September 9, 2019 15:58
Flask WTF custom validator
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
@daltonjorge
daltonjorge / rails_annotations.md
Created August 8, 2012 14:42 — forked from hakagura/rails_annotations.md
Explicações de conceitos do Rails e outras infos úteis.

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
@nicobytes
nicobytes / deploy-gh.sh
Last active August 3, 2020 20:14
Deploy gh-pages ionic pwa
#!/bin/bash
git branch -D gh-pages
git push origin --delete gh-pages
git checkout -b gh-pages
ionic build --prod
find . -type d ! -path './www*' ! -path './.git*' ! -path '.' | xargs rm -rf
rm -r *.*
mv www/* .
rm -rf www
git add .
def sendTelegram(message) {
def encodedMessage = URLEncoder.encode(message, "UTF-8")
withCredentials([string(credentialsId: 'telegramToken', variable: 'TOKEN'),
string(credentialsId: 'telegramChatId', variable: 'CHAT_ID')]) {
response = httpRequest (consoleLogResponseBody: true,
contentType: 'APPLICATION_JSON',
httpMode: 'GET',
url: "https://api.telegram.org/bot$TOKEN/sendMessage?text=$encodedMessage&chat_id=$CHAT_ID&disable_web_page_preview=true",
@Badgerati
Badgerati / CleanMSBuilds.ps1
Created May 14, 2015 14:54
PowerShell script for cleaning multiple projects/solutions in one command line via MSBuild
###########################################################################
# Author: Matthew Kelly (@Badgerati)
# Date: May 14 2015
#
# MSBuildPath: Path to where your MSBuild.exe file resides
# Projects: Array of Project/Solution files
# CleanDebug: Switch to clean build in debug mode
# CleanRelease: Switch to clean build int release mode
#
# Example: