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
@bergpb
bergpb / sources.list
Created July 18, 2017 00:35 — forked from kstroud1/sources.list
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
@bergpb
bergpb / rest-server.py
Created August 21, 2017 16:03 — forked from miguelgrinberg/rest-server.py
The code from my article on building RESTful web services with Python and the Flask microframework. See the article here: http://blog.miguelgrinberg.com/post/designing-a-restful-api-with-python-and-flask
#!flask/bin/python
from flask import Flask, jsonify, abort, request, make_response, url_for
from flask.ext.httpauth import HTTPBasicAuth
app = Flask(__name__, static_url_path = "")
auth = HTTPBasicAuth()
@auth.get_password
def get_password(username):
if username == 'miguel':
@bergpb
bergpb / huffman.py
Created October 24, 2017 10:53 — forked from mreid/huffman.py
Example implementation of Huffman coding in Python
# Example Huffman coding implementation
# Distributions are represented as dictionaries of { 'symbol': probability }
# Codes are dictionaries too: { 'symbol': 'codeword' }
def huffman(p):
'''Return a Huffman code for an ensemble with distribution p.'''
assert(sum(p.values()) == 1.0) # Ensure probabilities sum to 1
# Base case of only two symbols, assign 0 or 1 arbitrarily
if(len(p) == 2):
@bergpb
bergpb / pdf2txt.rb
Created November 17, 2017 17:57 — forked from emad-elsaid/pdf2txt.rb
PDF to Text converter using ruby
#!/usr/bin/env ruby
require 'pdf/reader' # gem install pdf-reader
# credits to :
# https://github.com/yob/pdf-reader/blob/master/examples/text.rb
# usage example:
# ruby pdf2txt.rb /path-to-file/file1.pdf [/path-to-file/file2.pdf..]
ARGV.each do |filename|
PDF::Reader.open(filename) do |reader|
@bergpb
bergpb / gist:0f6f89fb39684d5685e2fa64b2140e89
Created December 12, 2017 14:29 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@bergpb
bergpb / ngrok_url_api.js
Created January 30, 2018 02:22
Get ngrok public url in api with node.
//Execute with: node ngrok_url_api.js
const request = require("request");
const url = "http://127.0.0.1:4040/api/tunnels";
request.get(url, function(error, res, body) {
get_url = JSON.parse(body);
console.log(get_url.tunnels[0].public_url);
});
import os
import sys
#check if sys.argv is set:
if len(sys.argv) > 1:
dir = sys.argv[1]
else:
dir = os.getcwd()
#go to dir
@bergpb
bergpb / convert_doc_to_pdf.py
Last active April 11, 2018 11:36
Convert '.doc' into a '.pdf' file.
# -*- coding: utf-8 -*-
import os
#install this dependency
#sudo apt-get install unoconv
for file in os.listdir(os.getcwd()):
#remove all spaces in filename
new_file = file.replace(' ', '_')
@bergpb
bergpb / factorial_recursive.py
Last active April 16, 2018 19:11
Recursive factorial in python.
import sys
n = int(sys.argv[1])
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
<persistence-unit name="persistenceUnitName" transaction-type="RESOURCE_LOCAL">
<properties>
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" /> <!-- DB Driver -->