Skip to content

Instantly share code, notes, and snippets.

@FLamparski
FLamparski / index.html
Last active Aug 16, 2017
Setting properties - Object.assign vs assignment (https://jsbench.github.io/#03b950d3832a7fd24ea8909671a5db58) #jsbench #jsperf
View index.html
<!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>
View index.html
<!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 Nov 8, 2019
Git pre-commit hook for Fish to check if you're committing Jasmine tests that contain fdescribe or fit
View pre-commit.fish
#!/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
View index.html
<!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>
View index.html
<!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 Jun 26, 2017
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!
View package.json
"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 Apr 2, 2017
I'm playing with the language Pony. Here's me trying (badly) to figure out reference capabilities.
View notes.md

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 Jan 27, 2017
Hacky way to use shlex.split in PHP
View hack_shlex.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 Jan 13, 2017
BadORM - how easy can it be to write an "ORM"?
View Column.java
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 Dec 11, 2016
I may have just written an abomination
View SetOfLists.java
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 {
You can’t perform that action at this time.