Skip to content

Instantly share code, notes, and snippets.

Avatar
🙃

Artem Chistyakov temochka

🙃
View GitHub Profile
@temochka
temochka / karabiner.notes.json
Created Feb 25, 2021
An example of Anykey-like complex automation in karabiner.
View karabiner.notes.json
{
"title": "Notes automations",
"rules": [
{
"description": "Launch Apple Notes automations in Alfred",
"manipulators": [
{
"type": "basic",
"conditions": [
{
@temochka
temochka / GIANTS.md
Last active Jun 27, 2020
My Philly ETE 2020 references
View GIANTS.md
View snake-case-tokenizer.rb
#!/usr/bin/env ruby
while (path = gets)
filename = File.basename(path)
next if filename.start_with?('@')
filename.gsub(/\..+$/, '').split(/[_.]/).reject(&:empty?).each { |token| puts token }
end
@temochka
temochka / most-changed-dirs
Created May 20, 2019
Print often changed files and dirs.
View most-changed-dirs
#!/usr/bin/env ruby
# pipe the following command into this script:
# git log --pretty=format: --name-only | most-changed-dirs
counts = Hash.new { |hash, k| hash[k] = 0 }
while (filename = gets)
next if filename.start_with?('@')
parts = filename.strip.split(File::SEPARATOR).reject(&:empty?)
@temochka
temochka / current_tab_to_omni.js
Created Oct 4, 2017
Save current tab’s title and URL to OmniFocus via the quick entry dialog.
View current_tab_to_omni.js
var Safari = Application('Safari');
var OmniFocus = Application('OmniFocus');
var currentWindow = Safari.windows[0];
var currentTab = currentWindow.currentTab();
var task = OmniFocus.InboxTask({ name: currentTab.name(), note: currentTab.url() });
OmniFocus.quickEntry.open();
OmniFocus.quickEntry.inboxTasks.push(task);
View inline-postmark-templates.md

Template

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <body>
    <center><img src="cid:logo.png"/></center><br/>
    Hello {{name}}!
  </body>
@temochka
temochka / mad.clj
Last active Jul 6, 2017
4clojure #112
View mad.clj
(defn eval-expr [max-sum [sum sequence stack] lexeme]
(case lexeme
"[" [sum (conj sequence "(") (cons ")" stack)]
"]" [sum (conj sequence ")") (next stack)]
(let [x (Integer/parseInt lexeme)]
(if (<= (+ sum x) max-sum)
[(+ sum x) (conj sequence lexeme) stack]
(reduced [sum (concat sequence stack) nil])))))
(defn horribilis [max-sum program]
View 1_before.clj
(ns cursive-test)
(defn $render-digest
[{{{accept "accept"} :headers} :request
{:keys [date-range]} ::request
record ::entry}]
(let [digest (apply db/get-digest-data record date-range)]
(if (re-matches #"^application/json;?.*" accept)
(json/generate-string digest)
(ring-response {:headers {"Cache-Control" "max-age=0, private, no-cache, no-store, must-revalidate"
View Main.hs
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NamedFieldPuns #-}
module Main where
import Control.Monad
import Network.HTTP.Simple
import Network.HTTP.Client.TLS
import System.Environment
import System.Exit
View reader.rb
#!/usr/bin/env ruby
require 'timeout'
abort "Usage: #{$0} <file> [duration] [rps]" unless ARGV.size >= 1
filename, duration, rps = ARGV
duration = (duration || 5).to_i
rps = (rps || 100).to_i
pause = 1.0 / rps