Skip to content

Instantly share code, notes, and snippets.

@olih
olih / jq-cheetsheet.md
Last active May 3, 2024 17:42
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq

@joepie91
joepie91 / vpn.md
Last active May 3, 2024 10:58
Don't use VPN services.

Don't use VPN services.

No, seriously, don't. You're probably reading this because you've asked what VPN service to use, and this is the answer.

Note: The content in this post does not apply to using VPN for their intended purpose; that is, as a virtual private (internal) network. It only applies to using it as a glorified proxy, which is what every third-party "VPN provider" does.

  • A Russian translation of this article can be found here, contributed by Timur Demin.
  • A Turkish translation can be found here, contributed by agyild.
  • There's also this article about VPN services, which is honestly better written (and has more cat pictures!) than my article.
@Avaq
Avaq / combinators.js
Last active May 1, 2024 09:38
Common combinators in JavaScript
const I = x => x
const K = x => y => x
const A = f => x => f (x)
const T = x => f => f (x)
const W = f => x => f (x) (x)
const C = f => y => x => f (x) (y)
const B = f => g => x => f (g (x))
const S = f => g => x => f (x) (g (x))
const S_ = f => g => x => f (g (x)) (x)
const S2 = f => g => h => x => f (g (x)) (h (x))
@DrBoolean
DrBoolean / free-er.js
Last active March 17, 2024 10:33
Free(er) monads in JS (pt 1)
const daggy = require('daggy')
const compose = (f, g) => x => f(g(x))
const id = x => x
const kleisli_comp = (f, g) => x => f(x).chain(g)
//=============FREE=============
const Free = daggy.taggedSum({Impure: ['x', 'f'], Pure: ['x']})
const {Impure, Pure} = Free
@imjasonh
imjasonh / markdown.css
Last active February 12, 2024 17:18
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@paulmillr
paulmillr / less.less
Created March 9, 2012 08:26
Sass vs Stylus vs LESS
.border-radius (@radius) {
-webkit-border-radius: @radius;
-o-border-radius: @radius;
-moz-border-radius: @radius;
-ms-border-radius: @radius;
border-radius: @radius;
}
.user-list {
// need to use special `.` syntax
@DrBoolean
DrBoolean / coyo_uses.js
Created February 26, 2016 15:40
Coyoneda Uses in JS
const daggy = require('daggy')
const compose = (f, g) => x => f(g(x))
const id = x => x
//===============Define Coyoneda=========
const Coyoneda = daggy.tagged('x', 'f')
Coyoneda.prototype.map = function(f) {
return Coyoneda(this.x, compose(f, this.f))
}

Challenge

Write a function of type String -> Integer. The input may or may not be a valid JSON string. If it is valid, the resulting JavaScript value is expected to be an object, but may not be. If it is an object, it is expected to have a foo property whose value is expected to be an object, but may not be. This value is expected to have a bar property which is expected to be an object with a baz property whose value is expected to be an array of strings. Each of these strings is expected to be a hex representation of an integer (e.g. 0xFF). If every element of the array meets this expectation, the

@Avaq
Avaq / directories-my.sql
Last active February 16, 2019 21:23
Nested Directory Structure in SQL
-- Create our directories table.
CREATE TABLE `directories` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`lft` int(11) NOT NULL,
`rgt` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `directory_lft` (`lft`),
UNIQUE KEY `directory_rgt` (`rgt`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@DrBoolean
DrBoolean / free-er2.js
Created February 27, 2016 16:38
Free(er) Monads Pt2
const daggy = require('daggy')
const Task = require('data.task')
const _ = require('lodash')
const kleisli_comp = (f, g) => x => f(x).chain(g)
const compose = (f, g) => x => f(g(x))
const id = x => x
//=============FREE=============
const Free = daggy.taggedSum({Impure: ['x', 'f'], Pure: ['x']})
const {Impure, Pure} = Free