Skip to content

Instantly share code, notes, and snippets.

View stigok's full-sized avatar
🚢
ship it!

Stig Otnes Kolstad stigok

🚢
ship it!
View GitHub Profile
#!/bin/bash
# made for tghack '17
# desc: upload a file chunked through a shell with length
# restrictions of commands. you might need to manually
# tune the BUFLEN to stay within the limits. sh syntax
# errors appears when you're out of bounds.
#
# todo: progress bar
#
HOST=${1}
@dschep
dschep / raspbian-python3.6.rst
Last active October 24, 2023 14:57 — forked from BMeu/raspbian-python3.5.rst
Installing Python 3.6 on Raspbian

Installing Python 3.6 on Raspbian

As of January 2018, Raspbian does not yet include the latest Python release, Python 3.6. This means we will have to build it ourselves, and here is how to do it. There is also an ansible role attached that automates it all for you.

  1. Install the required build-tools (some might already be installed on your system).

@stigok
stigok / soundcloudplayer.js
Last active May 28, 2019 06:59
Angular.js SoundCloud player widget directive
angular.module('ngApp')
.directive('soundCloudPlayer', function () {
return {
restrict: 'E',
template: '<iframe width="100%" height="465" scrolling="no" frameborder="no"></iframe>',
link: function (scope, element, attrs) {
var iframe = element.find('iframe');
var settings = [
'buying=false',
'liking=false',
@grndrth
grndrth / gist:e739883687b14f8b060b
Created October 12, 2015 19:27
Setting up Karma with Mocha, Chai, Babel, CommonJS. Everything else in karma.conf.js can be left at standard settings.
// Karma configuration
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
@alexmcroberts
alexmcroberts / main.go
Last active February 17, 2022 11:52
Golang unmarshal JSON epoch in milliseconds from string to time.Time
package main
import (
"encoding/json"
"fmt"
"strconv"
"strings"
"time"
)
@paulirish
paulirish / what-forces-layout.md
Last active April 27, 2024 23:37
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent

Angular2 + JSPM cheat sheet

First time setup

  • install jspm beta: npm install -g jspm@beta
  • set up your project: jspm init
  • install dependencies: jspm install angular2 reflect-metadata zone.js es6-shim

This will create a jspm_packages folder, and a config.js file.

Open the config.js file - this file manages options for the System.js loader - tweak it as appropriate

@stigok
stigok / reset.css
Created April 28, 2015 18:38
reset.css with Eric Meyer CSS Reset + Paul Irish border-box: none
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
@ipmb
ipmb / ratelimit.nginxconf
Last active April 5, 2024 00:46
Nginx reverse proxy with rate limiting
upstream myapp {
server 127.0.0.1:8081;
}
limit_req_zone $binary_remote_addr zone=login:10m rate=1r/s;
server {
listen 443 ssl spdy;
server_name _;
@kennyledet
kennyledet / sqlalchemy_dupe_row
Created July 19, 2014 20:50
SQLAlchemy Duplicate Row
def copy_row(model, row, ignored_columns=[]):
copy = model()
for col in row.__table__.columns:
if col.name not in ignored_columns:
try:
copy.__setattr__(col.name, getattr(row, col.name))
except Exception as e:
print e
continue