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
# Based on https://gist.github.com/erykml/9b07b916ceee78c207d14fa2548b8f6f#file-hampel_filter_forloop_numba-py | |
import numpy as np | |
from numba import jit | |
@jit(nopython=True) | |
def hampel_filter_forloop_numba(input_series, window_length, n_sigmas=3): | |
if window_length % 2 == 0: | |
raise ValueError('window_length should be odd') |
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
defmodule Worker do | |
use GenServer | |
@delay 5 | |
defp work(source) do | |
IO.puts("work from #{source}") | |
end | |
# Client |
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
defmodule HeuristicInference do | |
@moduledoc """ | |
Heuristic to infer whether a list should be printed as charlist in IEx. | |
An improvement proposal. | |
""" | |
def should_print_as_charlist?([]) do | |
true | |
end |
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
defmodule App do | |
defmodule CLI do | |
def main(argv) do | |
io_stream_from_file_args_or_stdin(argv) | |
|> App.process_stream() | |
end | |
defp io_stream_from_file_args_or_stdin(argv) do | |
get_io_source(argv) | |
|> IO.stream(:line) |
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
[credential] | |
helper = cache --timeout=3600 | |
[user] | |
name = Adriano Mitre | |
email = adriano.mitre@gmail.com | |
[core] | |
editor = subl --wait | |
[alias] | |
# one-line log |
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
# AWS Version 4 signing example | |
# EC2 API (DescribeRegions) | |
# See: http://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html | |
# This version makes a GET request and passes the signature | |
# in the Authorization header. | |
import sys, os, base64, datetime, hashlib, hmac | |
import requests # pip install requests | |
import urllib |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>author</key> | |
<string>Michael Sheets</string> | |
<key>name</key> | |
<string>Twilight with GitGutter support</string> | |
<key>settings</key> | |
<array> |
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
# Ruby solution to http://www.beatmycode.com/challenge/5/show | |
class Integer # in real apps should use refinements instead of monkey patching | |
def prime? | |
return false if self < 2 | |
! 2.upto(self**0.5).any? { |n| self % n == 0 } | |
end | |
def rotations | |
n, ss = to_s.length, to_s * 2 |
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
# O( N log N ) | |
class Integer # in real apps should use refinements instead of monkey patching | |
def prime? | |
return false if self < 2 | |
! 2.upto(self**0.5).any? { |n| self % n == 0 } | |
end | |
def rotations | |
n, ss = to_s.length, to_s * 2 |
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
ActiveRecord::Migration.class_eval do | |
change_table :teams, :force => true do |t| | |
# copy and paste from migrations create_table block, e.g., | |
t.string :slug, unique: true | |
end | |
# specific commands | |
add_column :people, :cpf, :integer, null: false | |
remove_column :people, :cpf |
NewerOlder