Skip to content

Instantly share code, notes, and snippets.

View temochka's full-sized avatar
🪒
🐃

Artem Chistyakov temochka

🪒
🐃
View GitHub Profile
@temochka
temochka / karabiner.notes.json
Created February 25, 2021 22:52
An example of Anykey-like complex automation in karabiner.
{
"title": "Notes automations",
"rules": [
{
"description": "Launch Apple Notes automations in Alfred",
"manipulators": [
{
"type": "basic",
"conditions": [
{
@temochka
temochka / GIANTS.md
Last active June 27, 2020 07:44
My Philly ETE 2020 references
#!/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 19:47
Print often changed files and 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 / postmark_rails_headers.rb
Created April 29, 2014 14:39
An example of sending custom headers with postmark-rails and ActionMailer
class TestMailer < ActionMailer::Base
def email
headers['X-Tag-Via-Hash-Access'] = 'value'
headers 'X-Tag-Via-Headers-Method' => 'value'
mail(to: 'support@postmarkapp.com', from: 'tema@wildbit.com', subject: 'Headers test') do |format|
format.text { render text: 'Headers test' }
end
@temochka
temochka / current_tab_to_omni.js
Created October 4, 2017 00:32
Save current tab’s title and URL to OmniFocus via the quick entry dialog.
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);

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}}!
 
{-# 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
@temochka
temochka / mad.clj
Last active July 6, 2017 16:34
4clojure #112
(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]
(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"