Skip to content

Instantly share code, notes, and snippets.

@FLamparski
FLamparski / index.html
Last active August 16, 2017 10:32
Setting properties - Object.assign vs assignment (https://jsbench.github.io/#03b950d3832a7fd24ea8909671a5db58) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Setting properties - Object.assign vs assignment</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Delete vs undefined</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@FLamparski
FLamparski / pre-commit.fish
Last active November 8, 2019 07:22
Git pre-commit hook for Fish to check if you're committing Jasmine tests that contain fdescribe or fit
#!/usr/local/bin/fish
# should be 0 at the end of the file
set num_errors 0
# is the file a JS test?
function is_test -a file
echo $file | egrep '(src\/test\/js|\.spec\.js$)' > /dev/null
return $status
end
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Iteration stuff</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Object.values is slow</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@FLamparski
FLamparski / package.json
Created June 26, 2017 11:12
Hey, add this to your package.json to generate a self-signed cert for each project, then use it with webpack-dev-server https server!
"scripts": {
"serve-dev-secure": "cross-env NODE_ENV=development webpack-dev-server --inline --hot --progress --https --cert certs/cert.pem --key certs/key.pem",
"make-certs": "mkdir -p certs && openssl req -x509 -newkey rsa:4096 -keyout certs/key.pem -out certs/cert.pem -days 365 -nodes -subj '/CN=localhost'"
}
@FLamparski
FLamparski / notes.md
Last active April 2, 2017 11:41
I'm playing with the language Pony. Here's me trying (badly) to figure out reference capabilities.

Pony reference capabilities!

These specify what I can do with an object. They are specified on object level but can be used on variable level to constrain objects passed to stuff.

iso Isolated!

I own the thing. It is my thing. I am free

@FLamparski
FLamparski / hack_shlex.php
Created January 27, 2017 15:48
Hacky way to use shlex.split in PHP
<?php
/**
* Hacks around the fact that there isn't a good shell-style argument lexer
* for PHP by using the Python one.
* One argument: the line to parse as a shell line.
* Returns: An array such that:
* 'foo --bar baz\ foo "/bar/foo man/quux"' → ['foo', '--bar', 'baz foo', '/bar/foo man/quux']
* Caveat: no error handling. Depends on /usr/bin/python3 being python. It's horrible.
*/
function hack_shlex($str) {
@FLamparski
FLamparski / Column.java
Created January 13, 2017 23:44
BadORM - how easy can it be to write an "ORM"?
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@Retention(RUNTIME)
@Target(FIELD)
public @interface Column {
String name();
@FLamparski
FLamparski / SetOfLists.java
Created December 11, 2016 22:10
I may have just written an abomination
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Scanner;
public class SetOfLists {
private static
<COLL_INNER extends Collection<Integer>, COLL_OUTER extends Collection<COLL_INNER>>
COLL_OUTER collectionOfCollections(Scanner in, Class<COLL_OUTER> OuterCollection, Class<COLL_INNER> InnerCollection)
throws InstantiationException, IllegalAccessException {