Skip to content

Instantly share code, notes, and snippets.

@kevinmehall
kevinmehall / rust-cross-libs.sh
Last active November 3, 2023 13:23
Cross-compile Rust standard library for Tessel without full bootstrap build [A work in progress]
#!/bin/bash
# THIS IS A GIANT HACK
# if you think this would be a good idea if it weren't so terrible, go read https://github.com/rust-lang/rfcs/pull/1133
set -e
# Parse args
for i in "$@"
do
@nolanlawson
nolanlawson / protips.js
Last active February 4, 2024 18:06
Promise protips - stuff I wish I had known when I started with Promises
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");
@paulirish
paulirish / bling.js
Last active May 1, 2024 19:56
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
@Fornoth
Fornoth / Notes.md
Last active September 27, 2023 17:52
Makes a device show up in spotify connect devices list, but nothing else yet

#Python Script Setup

To get the python script running, run either pip install flask or pip install -r requirements.txt if you used git clone to clone the gist

#libspotify_embedded_shared.so notes

##Using the library (still in progress) There's a compile.sh that compiles a program that calls SpInit(), but doesn't get any farther because it needs more than just the API version number (which is 4)

##Spotify appkey

@p3t3r67x0
p3t3r67x0 / pseudo_elements.md
Last active January 16, 2024 01:17
A CSS pseudo-element is used to style specified parts of an element. In some cases you can style native HTML controls with vendor specific pseudo-elements. Here you will find an list of cross browser specific pseudo-element selectors.

Styling native elements

Native HTML controls are a challenge to style. You can style any element in the web platform that uses Shadow DOM with a pseudo element ::pseudo-element or the /deep/ path selector.

video::webkit-media-controls-timeline {
  background-color: lime;
}

video /deep/ input[type=range] {
@sphaero
sphaero / gstreamer-build.sh
Last active February 11, 2023 16:25
Install & build gstreamer from git
#!/bin/bash --debugger
set -e
BRANCH="master"
if grep -q BCM2708 /proc/cpuinfo; then
echo "RPI BUILD!"
RPI="1"
fi
[ -n "$1" ] && BRANCH=$1
@cabeca
cabeca / simulator_populator
Created September 23, 2014 21:30
This script removes and recreates all simulators in Xcode 6.
#!/usr/bin/env ruby
device_types_output = `xcrun simctl list devicetypes`
device_types = device_types_output.scan /(.*) \((.*)\)/
runtimes_output = `xcrun simctl list runtimes`
runtimes = runtimes_output.scan /(.*) \(.*\) \((com.apple[^)]+)\)$/
devices_output = `xcrun simctl list devices`
devices = devices_output.scan /\s\s\s\s(.*) \(([^)]+)\) (.*)/
@OrganicPanda
OrganicPanda / hacky-scrollbar-resize-listener.js
Last active April 7, 2024 10:53
A sham that will throw a window resize event even when scrollbars are added/removed (this is not something the standard window resize event does). Tested in IE9+, Chrome & Firefox latest.
// Demo: http://jsfiddle.net/pFaSx/
// Create an invisible iframe
var iframe = document.createElement('iframe');
iframe.id = "hacky-scrollbar-resize-listener";
iframe.style.cssText = 'height: 0; background-color: transparent; margin: 0; padding: 0; overflow: hidden; border-width: 0; position: absolute; width: 100%;';
// Register our event when the iframe loads
iframe.onload = function() {
// The trick here is that because this iframe has 100% width
@starstuck
starstuck / wheel-event-polyfill.js
Last active March 11, 2018 14:23
Mouse 'wheel' event polyfill for webkit browsers
/**
* Mouse wheel polyfill inspired by cross-browser example on mdn wiki.
*
* It supports relatively modern browsers, which already support addEventListener and Array forEach methods.
* Effectively it is targeting webkit based browsers. I didn't have opportunity to test it on old Firefox.
* Method addEventListener is supported in IE9, which already supports wheel event. I guess one could combine
* it with polyfill for addEventListener to have support in IE 6-8. In that case one would have to also wrap
* all addEventListener methods provided by the polyfill (last block below).
*
* @see https://developer.mozilla.org/en-US/docs/Web/Reference/Events/wheel?redirectlocale=en-US&redirectslug=DOM%2FMozilla_event_reference%2Fwheel#Listening_to_this_event_across_browser
@mayoff
mayoff / RobIntrinsicContentSizeHonoringContainerView.h
Created August 10, 2013 19:43
Untested UIView subclass to be used as the custom class of a container view in a storyboard, to make that container view honor the intrinsic content size of its embedded content view.
/**
Use this as the custom class of a container view in a storyboard if you want the container view to honor its embedded view's intrinsic content size.
*/
@interface RobIntrinsicContentSizeHonoringContainerView : UIView
/** Connect this to my width constraint in the storyboard if you want me to use my subview's intrinsic content width. */
@property (nonatomic, strong) IBOutlet NSLayoutConstraint *widthConstraint;
/** Connect this to my height constraint in the storyboard if you want me to use my subview's intrinsic content height. */
@property (nonatomic, strong) IBOutlet NSLayoutConstraint *heightConstraint;