Skip to content

Instantly share code, notes, and snippets.

View JakeSidSmith's full-sized avatar
💭
Being awesome 😎

Jake 'Sid' Smith JakeSidSmith

💭
Being awesome 😎
View GitHub Profile
@JakeSidSmith
JakeSidSmith / launch-chromium
Last active April 22, 2024 20:26
Openbox config to launch a full screen Chromium on Raspberry Pi running Raspbian Lite
# Disable any form of screen saver / screen blanking / power management
xset s off
xset s noblank
xset -dpms
# Allow quitting the X server with CTRL-ATL-Backspace
setxkbmap -option terminate:ctrl_alt_bksp
# Start Chromium in kiosk mode
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' ~/.config/chromium/'Local State'
@JakeSidSmith
JakeSidSmith / drinking-jenga.md
Created December 5, 2015 17:07
List of rules for Drinking Jenga

Drinking Jenga

Standard drinking rules (green)

Take

  • +1 - Take a swig
  • Double or nothing - Take 2
  • The magic number - Take 3
  • Steady as you go - Take 4
@JakeSidSmith
JakeSidSmith / exact-types.ts
Last active August 7, 2023 18:13
Strict types in TypeScript with getters and setters
/* Tested with TypeScript 2.4.2 */
// First we define an interface for our object
interface IThing {
id: string;
type: 'foo' | 'bar';
num?: number;
}
// Then we can use this Exact type to prevent type inference on our objects
@JakeSidSmith
JakeSidSmith / connection-monitor.py
Created March 6, 2015 11:34
Little python program for logging internet connection
import urllib2, time, socket
from datetime import datetime
previous_state = 'Monitoring started'
current_state = 'Monitoring started'
readable_time = None
time_now = None
disconnected_time = None
def start_monitoring():
@JakeSidSmith
JakeSidSmith / example.md
Last active March 4, 2021 09:52
TypeScript: inference of named arguments differs from positional arguments

TypeScript version: 4.2.2

tsconfig.json

{
  "compilerOptions": {
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noUncheckedIndexedAccess": true,
@JakeSidSmith
JakeSidSmith / css-icon-drag.css
Created November 11, 2016 13:05
A drag icon made with pure CSS
// https://jsfiddle.net/7Ldmmrjd/2/
span {
display: inline-block;
width: 16px;
height: 8px;
}
span,
span::before {
@JakeSidSmith
JakeSidSmith / with-click-outside.ts
Created April 24, 2019 12:58
React higher order component to add "click outside" events to elements
import React, { MouseEvent, PureComponent } from 'react';
interface Props {
onClickOutside: () => any;
}
// @TODO: element should be constrained to 'keyof ReactHTML' but this causes some crazy memory leak
export const withClickOutside = (element: string) => {
const Element = element;
@JakeSidSmith
JakeSidSmith / ascii.js
Last active April 11, 2019 16:14
Valid ascii art ES5 javascript variable names
// Info about available characters
// https://mathiasbynens.be/notes/javascript-identifiers
// Test your variable names
// https://mothereff.in/js-variables
const ǀʋ〇ᴥ〇ǀ = 'Jake the dog'; // Needs parenthesis-like wrapper
const ᗡo_oᗞ = 'Monkey or Deadmau5?';
const シ = 'Smile';
const ㇱ = 'Small smile';
@JakeSidSmith
JakeSidSmith / ellipsized-filenames.css
Last active March 13, 2019 17:42
CSS - ellipsis filename but keep extension
/* HTML
<div class="file">
<div class="icon"></div>
<span class="filename">
<span class="name">
Filename<span class="extension">.ext</span>
</span>
</span>