Skip to content

Instantly share code, notes, and snippets.

View zbennett10's full-sized avatar

Zachary Bennett zbennett10

View GitHub Profile
@mathiasbynens
mathiasbynens / escape.js
Created June 26, 2019 07:29
Escaping JSON-stringified data for use as a JavaScript string literal
// This object contains a string value that in contains a single quote,
// a double quote, a backtick, and a backslash.
const data = { foo: `a'b"c\`d\\e` };
// Turn the data into its JSON-stringified form.
const json = JSON.stringify(data);
// Now, we want to insert the data into a script body as a JavaScript
// string literal per https://v8.dev/blog/cost-of-javascript-2019#json,
// escaping special characters like `"` in the data.
@m-renaud
m-renaud / custom-decoder.elm
Created November 15, 2016 18:11
Custom decoder in elm 0.18
customDecoder decoder toResult =
Json.andThen
(\a ->
case toResult a of
Ok b -> Json.succeed b
Err err -> Json.fail err
)
decoder
@theplatapi
theplatapi / gist:0a7d789afc8028a3c20b
Last active November 26, 2023 05:55
Draw a rectangle in Cesium with shift-click-drag
var viewer = new Cesium.Viewer('cesiumContainer', {
targetFrameRate: 60,
homeButton: false,
sceneModePicker: false,
navigationHelpButton: false,
baseLayerPicker: false,
clock: new Cesium.Clock({
startTime: Cesium.JulianDate.fromIso8601('1880-01-01'),
currentTime: Cesium.JulianDate.fromIso8601('1880-01-01'),
stopTime: Cesium.JulianDate.fromIso8601("2013-12-01"),
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@wh1tney
wh1tney / deploy-static-site-heroku.md
Last active June 24, 2024 20:17
How to deploy a static website to Heroku

Gist

This is a quick tutorial explaining how to get a static website hosted on Heroku.

Why do this?

Heroku hosts apps on the internet, not static websites. To get it to run your static portfolio, personal blog, etc., you need to trick Heroku into thinking your website is a PHP app. This 6-step tutorial will teach you how.

Basic Assumptions

@staltz
staltz / introrx.md
Last active July 6, 2024 17:07
The introduction to Reactive Programming you've been missing
@falexandrou
falexandrou / sendfile.sh
Last active October 16, 2019 06:34
Turn Sendfile to "off" for vagrant boxes
# A VirtualBox bug forces vagrant to serve
# corrupt files via Apache or nginx
# The solution to that would be to turn off
# the SendFile option in apache or nginx
#
# If you use apache as your main web server
# add this directive in your httpd.conf (or apache.conf)
# configuration file name may vary in various systems
#
EnableSendfile off
# Redis configuration file example
# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
@indyfromoz
indyfromoz / aspnet-mvc.gitignore
Created November 19, 2012 06:44
.Gitignore for ASP.NET MVC
###################
# compiled source #
###################
*.com
*.class
*.dll
*.exe
*.pdb
*.dll.config
*.cache
@cecilemuller
cecilemuller / gist:3081382
Created July 10, 2012 05:40
PostgreSQL trigger: loop through the columns of the source table
DECLARE
_name text;
BEGIN
FOR _name IN SELECT column_name FROM information_schema.Columns WHERE table_schema = TG_TABLE_SCHEMA AND table_name = TG_TABLE_NAME LOOP
RAISE NOTICE 'Column is %', _name;
END LOOP;
RETURN NEW;
END