This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function toIconifyIcon(svg: string): IconifyIcon { | |
const body = svg.replace(/<svg[^>]*>/, "").replace(/<\/svg>/, ""); | |
const width = svg.match(/width="(\d+)"/)?.[1]; | |
const height = svg.match(/height="(\d+)"/)?.[1]; | |
return { | |
body: `<g fill="currentColor">${body}</g>`, | |
width: width ? Number.parseInt(width) : undefined, | |
height: height ? Number.parseInt(height) : undefined, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type ListDiff<T> = | |
| { type: "insert"; value: T; before?: T } | |
| { type: "remove"; value: T }; | |
/** | |
* Virtual DOM like diff algorhtim for arrays | |
*/ | |
export function listDiff<T extends { key: string }>( | |
before: T[], | |
after: T[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Atom } from 'mobx' | |
import * as firebase from 'firebase' | |
// Custom observable for Firebase value | |
// see https://mobx.js.org/refguide/extending.html | |
export class FirebaseWatcher<T> { | |
private atom: Atom | |
private ref?: firebase.database.Reference | |
private _value: T |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="todo-list"> | |
<div class="todo"> | |
<input type="checkbox" class="done"> | |
<h3 class="title">Title</h3> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_ssid | |
airport = '/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I' | |
`#{airport}`.split("\n").each do |line| | |
words = line.split | |
if words[0] == 'SSID:' | |
return words[1] | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <type_traits> | |
#include <vector> | |
#include <iostream> | |
#include <cstdlib> | |
#include <ctime> | |
#include <cmath> | |
template <typename TImpl> | |
class Enumerator | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <iostream> | |
#include <type_traits> | |
#include <boost/preprocessor.hpp> | |
#define GET_TYPE(n, array) \ | |
BOOST_PP_TUPLE_ELEM(2, 0, BOOST_PP_ARRAY_ELEM(n, array)) | |
#define GET_ARG(n, array) \ | |
BOOST_PP_TUPLE_ELEM(2, 1, BOOST_PP_ARRAY_ELEM(n, array)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DoNotation | |
class DSL | |
def initialize(&block) | |
@first_lets = [] | |
@proc_sources = [] | |
@variables = Hash[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'parslet' | |
require 'pp' | |
class Parser < Parslet::Parser | |
rule(:lparen) { str('(') >> space? } | |
rule(:rparen) { str(')') >> space? } | |
rule(:space) { match('\s').repeat(1) } | |
rule(:space?) { space.maybe } | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = 5 | |
y = 10 | |
add = (x, y) => | |
x + y | |
end | |
z = add x, y | |
times = (i, fn) => | |
iteration = (j) => | |
switch j < i |
NewerOlder