Skip to content

Instantly share code, notes, and snippets.

@localhostdotdev
localhostdotdev / 20.json
Last active Jul 22, 2019
Twitter datacenters by id, located by tweets around with the corresponding ids, best viewed on Github Desktop version (not on mobile's github). Each file name is a datacenter id, the points on the map are the different users who used that datacenter
View 20.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View test.md

ABAP

{% def random n:1 %}
  {% if n|equal 1|or (n|is_a "float") %}
    {{|rand|times n}}
  {% else %}
    {{|rand|times n|round}}
  {% end %}
{% end %}
View template.pegjs
{ function j(string) { return string.join('') } }
template =
(
interpolation /
tag /
$(!interpolation !tag .)
)+
ws = (" " / "\n")*
View liquid.peg.erl
text <- string:blob (object:object text:text
/ tag:tag text:text
% / open_tag:open_tag text:text
/ open_object:open_object text:text)?
blob <- (!open_object !open_tag .)*
object <- open_object:open_object space (argument:argument filters:filters / argument:argument)? space close_object:close_object
tag <- cond_if_tag / cond_unless_tag / cond_case_tag / assign_tag / comment_tag
View post fetch rails json with csrf token.coffee
post = (url, body) ->
token = document.querySelector('meta[name="csrf-token"]').attributes.content.value
fetch("#{url}.json",
method: "POST"
mode: "cors"
cache: "no-cache"
credentials: "same-origin"
headers:
"Content-Type": "application/json"
@localhostdotdev
localhostdotdev / hex-to-cterm.rb
Created May 11, 2019
hex color to cterm color, mainly for vim to translate hex color to cterm colors in colorscheme
View hex-to-cterm.rb
#!/usr/bin/env ruby
if ARGV.size != 1 || ARGV[0] !~ /#[0-9a-fA-F]{3,6}/
abort "USAGE: hex-to-cterm HEX"
end
def hex_to_rgb(hex)
rgb = hex.gsub('#', '').chars
if rgb.size == 3
View chromium-components (issues categories, labels).txt
Blink
Blink>Bluetooth
Blink>CSS
Blink>Canvas
Blink>DOM
Blink>Network>FetchAPI
Blink>Paint
Blink>PerformanceAPIs
Blink>Scroll
Blink>Storage>FileSystem
View graph + ruby code.md

graphiz nodes

puts Contact.all.map { |c| "C#{c.id} [style=filled,color=greenyellow]"  } +
  Book.all.map { |b| "B#{b.id} [style=filled,color=lightcyan]" } +
  BookContact.all.map { |bc| "C#{bc.contact_id} -> B#{bc.book_id}" }
digraph G {
View dream game.md
  • there is a fixed width/height rectangle board
  • players are circles
  • every player start at size 10 let's say
  • when somebody goes off the board (player B) the last player (A) who touched player B gets half of its "weight" added
    • perimeter is pi * r**2
    • so the new perimeter is (pi * rA**2) + (pi * rB**2)/2
    • new radius is pi * r**2 = (pi * rA**2) + (pi * rB**2)/2
    • r = sqrt(((pi * rA**2) + (pi * rB**2)/2)/2)
  • acceleration is proportional to weight (so the larger the slower)
  • when touching another player forces are distributed by weight (e.g. small player can't push large player much)
View rails-content-for-bug.md

content_for(:false) { false }

  • content_for?(false) false
  • content_for(false) nil
  • yield(false) ""

content_for(:true) { true }

  • content_for?(true) false