Skip to content

Instantly share code, notes, and snippets.

View x-raizor's full-sized avatar

Andrew Shapiro x-raizor

View GitHub Profile
@MaksimRudnev
MaksimRudnev / README.md
Last active March 3, 2024 05:02
Branching pipes

Pipe helpers

Here are three little functions that allow for brunching logical pipes as defined in magrittr package. It is against Hadley's idea, as pipes are in principle linear, and in general I agree, but sometimes it would be comfy to ramify pipes away. It overcomes native magrittr %T>% by allowing more than one step after cutting the pipe. Imagine you need to create a list with means, correlations, and regression results. And you like to do it in one single pipe. In general, it is not possible, and you'll have to start a second pipe, probably doing some redundant computations. Here is an example that allows it:

  ramify(1) %>%
    branch(1) %>% colMeans %>%
    branch(2) %>% lm(a ~ b, .) %>% broom::tidy(.) %>%
@tukachev
tukachev / ru_tiled_map.R
Created July 24, 2018 17:33
Плиточная карта РФ
library(geofacet)
library(ggplot2)
mygrid <- data.frame(
row = c(1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8,
8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11),
col = c(1, 5, 18, 19, 4, 10, 1, 12, 17, 18, 3, 4, 5, 9, 10, 15, 12, 13, 8, 9,
10, 17, 18, 20, 1, 3, 14, 15, 16, 4, 5, 6, 7, 12, 13, 7, 8, 9, 10, 17,
14, 15, 16, 3, 4, 5, 6, 12, 7, 8, 9, 10, 18, 13, 14, 15, 16, 3, 4, 5,
@nalgeon
nalgeon / cities.md
Last active March 28, 2024 01:19
Города России с координатами
@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active June 29, 2024 15:54
How to add a collapsible section in markdown.

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux
@sliminality
sliminality / Default (OSX).sublime-keymap
Last active October 8, 2023 04:47
Racket and Sublime Text 3
{
// Evaluate file in the open SublimeREPL.
// Depends on you creating the Packages/User/EvalInREPL.sublime-macro file.
{ "keys": ["super+r"], "command": "run_macro_file", "args": { "file": "Packages/User/EvalInREPL.sublime-macro" },
"context": [
{ "key": "selector", "operator": "equal", "operand": "source.elm" }
]
},
// Reindent selection on tab
@phaistonian
phaistonian / Select Similar.sketchplugin
Last active August 29, 2015 14:06
Sketch: Select similar layers or groups based on a number of properties (and guesses)
// Select Similar (ctrl shift a)
// https://gist.githubusercontent.com/phaistonian/b3737cf05c1b6a61dbb7/raw/1f1ca90f1c72e395cb4d2abfc23315c47dc5c25d/Select%20Similar.sketchplugin
/* Based on initial work by Ale Muñoz */
(function(){
var sel = selection[0], all_layers = [[doc currentPage] children];
if (sel) {
var query = getIdForElement(sel), type = [sel className], found = 0;
@mbostock
mbostock / .block
Last active June 28, 2016 22:41 — forked from mbostock/.block
Mitchell’s Best-Candidate
license: gpl-3.0
@lorenzopolidori
lorenzopolidori / has3d.js
Last active December 4, 2020 10:52 — forked from webinista/has3d.js
Testing for CSS 3D Transforms Support
function has3d(){
if (!window.getComputedStyle) {
return false;
}
var el = document.createElement('p'),
has3d,
transforms = {
'webkitTransform':'-webkit-transform',
'OTransform':'-o-transform',
@sgergely
sgergely / gist:3793166
Created September 27, 2012 09:43
Midnight Commander Keyboard Shortcuts for Mac OSX
----- Esc -----
Quick change directory: Esc + c
Quick change directory history: Esc + c and then Esc + h
Quick change directory previous entry: Esc + c and then Esc + p
Command line history: Esc + h
Command line previous command: Esc + p
View change: Esc + t (each time you do this shortcut a new directory view will appear)
Print current working directory in command line: Esc + a
Switch between background command line and MC: Ctrl + o
Search/Go to directory in active panel: Esc + s / Ctrl + s then start typing directory name
@crizCraig
crizCraig / gist:2816295
Created May 27, 2012 22:52
Download images from Google Image search using Python
import json
import os
import time
import requests
from PIL import Image
from StringIO import StringIO
from requests.exceptions import ConnectionError
def go(query, path):
"""Download full size images from Google image search.