Skip to content

Instantly share code, notes, and snippets.

Avatar
🤔

Duke dukex

🤔
View GitHub Profile
View linearregression.rb
# Adapted from a C# example here:
# http://stackoverflow.com/questions/43224/how-do-i-calculate-a-trendline-for-a-graph
# And thanks to John Esser for helping figure out how to
# calculate the targets to stabilize a negative slope!
class LinearRegression
attr_accessor :slope, :intercept
# Pass in an array of values to get the regression on
@dukex
dukex / sketch.sh
Created Feb 13, 2017 — forked from jackbillstrom/sketch.sh
The magic timetraveler script for Sketch trial
View sketch.sh
#!/bin/sh
echo "Traveling back in time..."
date 0318125013
echo "Opening Sketch..."
open -a Sketch
echo "Traveling to present time..."
ntpdate -u time.apple.com
echo "Done..."
exit 0
@dukex
dukex / 5.c
Last active Sep 7, 2015 — forked from anonymous/5.c
Avaliação 1
View 5.c
#include <stdio.h>
int main(int argc, char const *argv[]) {
int a, b, temp;
scanf("%d", &a);
scanf("%d", &b);
temp = a;
a = b;
b = temp;
printf("\n Agora a=%d e b=%d\n", a, b);
View gist:9bc54810a4cba54d94c2
# place this file in ~/.config/terminator/config
[global_config]
title_transmit_bg_color = "#d30102"
focus = system
[keybindings]
reset_clear = <Ctrl>R
new_tab = <Ctrl>T
split_horiz = <Ctrl><Shift>E
split_vert = <Ctrl>E
close_term = <Ctrl><Shift>W
View Makefile
# Baixa resultados do TSE desde 1989 e cria um CSV com os parlamentares eleitos com colunas:
# ano, uf, nome, cargo, situação, partido
ANOS_UF := 1989 1990
ANOS_MUNZONA := 1994 1996 1998 2000 2002 2004 2006 2008 2010 2012 2014
ARQUIVOS_UF := $(patsubst %, VOTACAO_CANDIDATO_UF_%.ZIP, $(ANOS_UF))
ARQUIVOS_MUNZONA := $(patsubst %, votacao_candidato_munzona_%.zip, $(ANOS_MUNZONA))
ARQUIVOS_MUNZONA_DEPENDENCIES := $(patsubst %, votacao_candidato_munzona_%_SP.txt, $(ANOS_MUNZONA))
ARQUIVOS_UF_DEPENDENCIES := $(patsubst %, VOTACAO_CANDIDATO_UF_%, $(ANOS_UF))
View gist:5727384
var humanize_time = function(time){
return time > 9 ? time : "0"+time;
}
var milliseconds = 17916;
date = new Date(milliseconds);
humanize_time(date.getUTCMinutes()) + ':' + humanize_time(date.getUTCSeconds());
nowadays: 00:17
expected: 00:17
View integration_test.rb
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'machinist/active_record'
require 'machinist/caching/active_record'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
spec_support = Rails.root.join("spec/support/**/*.rb")