Skip to content

Instantly share code, notes, and snippets.

Before:

Calculating -------------------------------------
              parse:     1.070M memsize (     0.000  retained)
                         9.862k objects (     0.000  retained)
                        50.000  strings (     0.000  retained)
             render:   769.826k memsize (    45.461k retained)
                         4.093k objects (   292.000  retained)
                        50.000  strings (    30.000  retained)
     parse & render:     1.827M memsize (     0.000  retained)

Before:

Warming up --------------------------------------
              parse:    10.000  i/100ms
             render:    18.000  i/100ms
     parse & render:     6.000  i/100ms
Calculating -------------------------------------
              parse:    101.008  (± 0.0%) i/s -      1.020k in  10.098326s
             render:    179.594  (± 1.1%) i/s -      1.800k in  10.024423s
 parse & render: 60.880 (± 0.0%) i/s - 612.000 in 10.052594s
# Liquid Template:
{{ "Hello World" }}
{{ "Hello World" }}
{{ "Hello World" }}
# VM's constants arry before the refactor:
constants = [
"Hello World",
"Hello World",
"Hello World"
@ggmichaelgo
ggmichaelgo / simple-liquid-c-template
Created February 20, 2022 21:58
Simple liquid template
0x0000: render_variable_rescue(line_number: 1)
0x0004: push_const("Hello World")
0x0007: push_const(" ")
0x000a: builtin_filter(name: :split, num_args: 2)
0x000d: builtin_filter(name: :first, num_args: 1)
0x0010: pop_write
0x0011: write_raw("\n")
0x0014: leave
@ggmichaelgo
ggmichaelgo / rabbit.rb
Last active December 3, 2021 04:59
rabbit.rb
$holes = Array.new(100, false)
answer = rand($holes.count)
$holes[answer] = true
puts "Bunny is at index: #{answer}"
def move_bunny
bunny_index = $holes.index(true)
$holes[bunny_index] = false
@ggmichaelgo
ggmichaelgo / benchmark.rb
Last active March 9, 2022 01:47
Liquid-C benchmark
# This is a very basic benchmark of Liquid-c rendering.
# Tested with
# Ryzen 5 2600
# 32GB Ram
# Ubuntu 18.04.6 LTS
require "benchmark/ips"
require "liquid"
require "liquid/c"
@ggmichaelgo
ggmichaelgo / scrape.rb
Created June 12, 2020 23:53
quick and dirty facebook people search
page_number = 1
cookie = "ENTER_BROWSER_COOKIE"
while page_number < 100
output = `curl 'https://www.facebook.com/ajax/pagelet/generic.php/BrowseScrollingSetPagelet?fb_dtsg_ag=AQw6hoTe38yJp40L_y3ncgCvQkx7MQqxmtaUV4hnBsHM_w%3AAQzATFpt6xYjICrfWAflKY7oj9UYpxro21VPvYDNM7SZXg&data=%7B%22view%22%3A%22list%22%2C%22encoded_query%22%3A%22AbqXtIHFno6JIcimtcWtd0YSjARE8tgBkIZl18cpITc5JX-HYDHCEEnwSORGJCMXl3gLEbatQtGhVisqDpR3OTn9kKOSWfvahqWAb0iiazh5UzIbzuOcGg0eiO6dbnR9PR-gOS12i9Ec3irYHn4-_pRm00P81Y44HBRbpIT1ZyE1ureSp-lzjgV1lam6eaRdCJD-b7iO6HIoMGroHAxi87aWMZlavfwVVLKWFeBA03dhjw-rJBNURt_33jg2k8CUFtCVQnB_W7y7JG1pztAXKRAiUwi_Ga5fkmUPFgt1sLsINvVsz749NTzxg59pRN2yDp3HsCS4HvcqFRaLVCpb2iuCtBMO_6NKRhKpBL3GDB-1zj7weMzF_vObOp8gqS_TrrdZSHL07B-qDYtQ2tEaAEP8w1rkyRBtID7AmJxohIFwbmtfGqZuZJxTXDyCEaI7ZARUq4YlGRn9uH94Fnt7jmQmXy33tOj9opHdP9i3BrLL15epmOPDNahFKkG698IzENVFBHPoOr5BMk9oXHB1Yo7c6Q0mAnD1E1_gRjcr5DO1dHDTYZgfnQTBieZ12eMw7_W9zp12ZK_Tinsrc3qKQali92O3qPnntJRC3l-1QyFoFOjHCnBQNFJE_OuFaeijulGR-dbhYJTr84v7Z5YjbDQZgWU-U33sQsLHipOI9JBvULC3kVm
@ggmichaelgo
ggmichaelgo / gist:29ee4e52188c6545bc5a
Last active August 29, 2015 14:05
Number + Number Anagram
Used Ruby and markburns' numbers_in_words
https://twitter.com/tweetsauce/status/500289520235859970
one plus twelve :: two plus eleven
one plus twelve :: eleven plus two
one plus twenty two :: two plus twenty one
one plus twenty two :: twenty one plus two
one plus twenty three :: three plus twenty one
one plus twenty three :: twenty one plus three
import java.util.Scanner;
public class Floyd
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
for(int n=0 ; n<3 ; n++)
{
int number = input.nextInt();