Skip to content

Instantly share code, notes, and snippets.

View CyrusNuevoDia's full-sized avatar
🐉
Kaizen

Cyrus CyrusNuevoDia

🐉
Kaizen
View GitHub Profile
defmodule Repo do
use Task
require Logger
@moduledoc """
It's hard to find the docs for the MongoDB adapter. Here's a direct link:
https://hexdocs.pm/mongodb/Mongo.html
"""
def start_link(_) do
@CyrusNuevoDia
CyrusNuevoDia / rails-session
Last active May 22, 2018 15:49
An AppleScript to get a Rails server, console, and general session open in iTerm.
#!/usr/bin/env osascript -l JavaScript
function open(name) {
var application = Application(name);
application.running() || application.open();
return application;
}
function bootstrapTerminal(project) {
var terminal = open("iTerm");
import os
import csv
import json
import re
from datetime import datetime
from urllib.request import urlopen
from urllib.parse import urlencode
os.chdir(os.path.dirname(__file__))
G1 = { 1: [2, 5],
2: [1, 3],
5: [4] }
G2 = { 1: [2, 4],
2: [3, 4],
3: [5],
5: [2, 6] }
G3 = { 1: [2, 5],
2: [3],
5: [4] }
G1 = { 1: [2, 5],
2: [1, 3],
5: [4] }
G2 = { 1: [2, 4],
2: [3, 4],
3: [5],
5: [2, 6] }
G3 = { 1: [2, 5],
2: [3],
5: [4] }

Keybase proof

I hereby claim:

  • I am knrz on github.
  • I am knrz (https://keybase.io/knrz) on keybase.
  • I have a public key ASCJ48JeXy8WhOQrwZKIYe_JM6313bXFxV00SQfJmU_1BQo

To claim this, I am signing this object:

class Chain < Struct.new(:value)
def method_missing(method, *args, &block)
next_value = self.value.public_send(method, *args, &block)
self.value = next_value unless method.to_s[-1] == "!"
self
end
end
# Now you can chain bang methods (or regular methods)!
Chain.new([1, 2, 3, 4, 5]).reject!(&:odd?).reverse!.value # => [4, 2]
class Salary
attr_reader :total_compensation
def initialize(base:, bonus_percentage: 0, seniority_factor: 0, deduction:)
@total_compensation = base.tap do |n|
n += n * bonus_percentage
n += n * seniority_factor
n -= deduction
end
end
import requests
TOKEN = ""
BASE = "https://api.telegram.org/bot{0}".format(token)
def send_message(params):
if "chat_id" not in params or "text" not in params:
return
return requests.get(BASE + "/sendMessage", params=params)
def delete_all(collection, value) when is_list(collection) do
List.foldr collection, [], fn
x, acc when x == value ->
acc
x, acc ->
[x|acc]
end
end