Skip to content

Instantly share code, notes, and snippets.

@JerryFleming
JerryFleming / shutdown.sh
Last active April 18, 2018 03:00
Shutdown your PC with graphical confirm dialog.
#!/bin/bash
# Shutdown the system, with GUI confirm box.
# by Jerry Fleming <[email protected]>,
# on Jun 7, 2013,
# improved on Dec 20, 2013, for systemd compatibility.
# Use at your own risks!
TIME=3 # Three minutes count down.
PATH=$PATH:/sbin # For the shutdown command to be found.
TITLE='Shutdown Confirm'
@sebmarkbage
sebmarkbage / Enhance.js
Last active June 19, 2025 19:41
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@dpapathanasiou
dpapathanasiou / MatrixDSL.scala
Created July 26, 2015 23:54
DSL processing in Scala
/* This is a scala solution for a mini domain specific language (DSL)
* defining instructions for populating an empty matrix.
*
* Input consists of a single string separated by spaces:
* - the first number represents the size of the matrix, NxN
* - the rest of the input consists of one or more strings defining
* the range of cells and how each of their populations will be
* incremented
*
* Increment pattern possibilities:
@baraldilorenzo
baraldilorenzo / readme.md
Last active September 13, 2025 12:17
VGG-16 pre-trained model for Keras

##VGG16 model for Keras

This is the Keras model of the 16-layer network used by the VGG team in the ILSVRC-2014 competition.

It has been obtained by directly converting the Caffe model provived by the authors.

Details about the network architecture can be found in the following arXiv paper:

Very Deep Convolutional Networks for Large-Scale Image Recognition

K. Simonyan, A. Zisserman

@paulirish
paulirish / what-forces-layout.md
Last active September 28, 2025 11:43
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
@mypetyak
mypetyak / unicode_sandwich.py
Created November 1, 2015 21:19
Unicode Sandwich, demonstrating multiple encodings.
# -*- encoding: utf-8 -*-
import re
# Byte string containing an Icelandic pangram encoded in mac_iceland
input = 'Svo h\x9alt, yxna k\xe0r \xdfeg\xddi j\x9c um d\x97p \x92 f\x8e \x87 b\xbe.'
# Create a Unicode object from the string, decoding with the mac_iceland
# encoding
u_string = input.decode('mac_iceland')
re.sub(r'\w{4}', u'xxxx', u_string, flags=re.UNICODE)
@vasanthk
vasanthk / System Design.md
Last active September 29, 2025 05:20
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@vanvaridiksha
vanvaridiksha / csds-spark.md
Last active July 3, 2017 15:51
Spark Assignment 3

#Spark Assignment 3

This assignment is based on the 3rd chapter of the book - 'Advanced Big Data Analytics with Spark'. You can find a copy of the book here.

In this assignment, you will be required to build a recommendation system using Spark and MLib using a dataset published by AudioScrobbler. This data is 500MB uncompressed and can be downloaded here.

You can glance through the chapter and understand how to build the recommendation system. The chapter will walk you through Scala code;

@josh-padnick
josh-padnick / download.sh
Last active September 12, 2024 06:36
Download a private binary release file from GitHub in bash
#!/usr/bin/env bash
#
# This is an adaptation of code I wrote to download a private binary from GitHub. Such...pain.
# Why can't GitHub just offer a standardized URL you can download a release binary from and attach
# your Github Personal Access Token as a header?
#
# Since this code is an adaptation it hasn't been directly tested, but the code it was adapted from works
# and hopefully you can get the missing piece you're after by looking here.
#
@nvictus
nvictus / runlength.py
Last active March 25, 2025 20:47
NumPy run-length encoding / decoding
"""Run Length Encoding utilities for NumPy arrays.
Authors
-------
- Nezar Abdennur
- Anton Goloborodko
"""
from __future__ import division, print_function
import numpy as np