This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PROGRAMS=(phpmd php-cs-fixer phpcpd phploc) | |
for PROGRAM in ${PROGRAMS[*]}; | |
do | |
command -v $PROGRAM >/dev/null 2>&1 || { echo "I require $PROGRAM but it's not installed. Aborting." >&2; exit 1; } | |
done | |
echo "=======================================================================================" | |
echo "Fixing code standard" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To run php on sublime: | |
* Select Tools->Build System->New Build System | |
* Copy the following code to the created file: | |
{ | |
"cmd" : ["php", "$file"], | |
"file_regex" : "php$", | |
"selector" : "source.php" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cheerio = require('cheerio'); | |
var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest; | |
function httpGet(theUrl) { | |
var xmlHttp = new XMLHttpRequest(); | |
xmlHttp.open("GET", theUrl, false); // false for synchronous request | |
xmlHttp.send(null); | |
return xmlHttp.responseText; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Solves the "Miojo with 2 hourglasses" problem | |
# cooking time and both hourglass times are passed as arguments, as in the following sample: | |
# ruby miojoproblem.rb 3 5 7 | |
# returns the minimum total time to cook the miojo accurately, or a fail message if not possible | |
# Solution is ad-hoc, can probably be optimized a lot | |
raise "Must specify 3 inputs: Miojo cooking time, hourglass 1 time, hourglass 2 time." if ARGV.length != 3 | |
cook_time = ARGV[0].to_i | |
hg_1 = ARGV[1].to_i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Calculates geometric distances between all given points | |
# coordinates are passed as arguments, as in the following sample: | |
# ruby geodistance.rb 62.425,52.424 42.0,90.5256 0.0,0.0 90.0,-180.0 | |
# returns the distance in kilometers | |
## | |
# Haversine Distance Calculation Function | |
# | |
# by https://gist.github.com/timols/5268103 | |
# Accepts two coordinates in the form |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Silly code to generate all combinations of species, background and gods that spell english words (according to NLTK) | |
# for Dungeon Crawl Stone Soup (as of 0.23) | |
from nltk.corpus import words | |
species = [ | |
"Ba", | |
"Ce", | |
"DD", | |
"DE", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
def split(filehandler, delimiter=',', row_limit=10000, | |
output_name_template='output_%s.csv', output_path='.', keep_headers=True): | |
""" | |
Splits a CSV file into multiple pieces. | |
A quick bastardization of the Python CSV library. | |
Arguments: | |
`row_limit`: The number of rows you want in each output file. 10,000 by default. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
import csv | |
import pandas as pd | |
def main(): | |
database_file = "CNPJ_full.db" | |
conn = conn = sqlite3.connect(database_file) | |
df = pd.read_sql_query("SELECT * FROM empresas WHERE municipio='PELOTAS'", conn) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dash | |
from dash import dcc | |
from dash import html | |
from dash.dependencies import Input, Output | |
import dash_bootstrap_components as dbc | |
import plotly_express as px | |
import plotly.graph_objects as go | |
import numpy as np |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"emmet.syntaxProfiles" : { | |
"javascript" : "jsx" | |
}, | |
"workbench.startupEditor" : "newUntitledFile", | |
"editor.fontSize" : 16, | |
"javascript.suggest.autoImports" : true, | |
"javascript.updateImportsOnFileMove.enabled" : "always", | |
"editor.rulers" : [ | |
80, |
OlderNewer