Skip to content

Instantly share code, notes, and snippets.

@maxchuquimia
maxchuquimia / SoundPlayer.swift
Created June 16, 2016 03:43
Super simple SoundFont (.sf2 or .dls) player example in Swift
//
// SoundPlayer.swift
// SoundPlayer
//
// Created by Max Chuquimia on 16/06/2016.
//
import Foundation
import AVFoundation
@jagrosh
jagrosh / Github Webhook Tutorial.md
Last active June 7, 2024 04:59
Simple Github -> Discord webhook

Step 1 - Make a Discord Webhook

  1. Find the Discord channel in which you would like to send commits and other updates

  2. In the settings for that channel, find the Webhooks option and create a new webhook. Note: Do NOT give this URL out to the public. Anyone or service can post messages to this channel, without even needing to be in the server. Keep it safe! WebhookDiscord

Step 2 - Set up the webhook on Github

  1. Navigate to your repository on Github, and open the Settings Settings
@wiledal
wiledal / template-literals-3-for-loops.js
Last active March 13, 2023 22:47
Template Literals example: For loops
/*
Template literals for-loop example
Using `Array(5).join(0).split(0)`, we create an empty array
with 5 items which we can iterate through using `.map()`
*/
var element = document.createElement('div')
element.innerHTML = `
<h1>This element is looping</h1>
${Array(5).join(0).split(0).map((item, i) => `
@kripken
kripken / hello_world.c
Last active January 17, 2024 12:15
Standalone WebAssembly Example
int doubler(int x) {
return 2 * x;
}
@branflake2267
branflake2267 / main.dart
Last active April 6, 2018 16:35
Flutter - The Infinite ListView - YouTube episode source code...
import 'dart:async';
import 'package:MyListViewApplication/models.dart';
import 'package:flutter/material.dart';
void main() {
runApp(new MyApp());
}
final ThemeData _themeData = new ThemeData(
primaryColor: Colors.blue,
@jwir3
jwir3 / canvasArrowhead.js
Created May 18, 2017 15:18
Code to create an arrowhead on an html5 canvas
/**
* Draw an arrowhead on a line on an HTML5 canvas.
*
* Based almost entirely off of http://stackoverflow.com/a/36805543/281460 with some modifications
* for readability and ease of use.
*
* @param context The drawing context on which to put the arrowhead.
* @param from A point, specified as an object with 'x' and 'y' properties, where the arrow starts
* (not the arrowhead, the arrow itself).
* @param to A point, specified as an object with 'x' and 'y' properties, where the arrow ends
@collinjackson
collinjackson / main.dart
Last active August 17, 2023 20:06
PageView example with dots indicator
// Copyright 2017, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:math';
import 'package:flutter/material.dart';
void main() {
runApp(new MyApp());
}
@simongregory
simongregory / promised-event-with-timeout.js
Created June 21, 2017 13:37
Wrap a Javascript event in a Promise with a time out.
function waitForEventWithTimeout(emitter, eventName, timeout) {
return new Promise((resolve, reject) => {
let timer;
function listener(data) {
clearTimeout(timer);
emitter.removeEventListener(eventName, listener);
resolve(data);
}
@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active June 11, 2024 03:27
How to add a collapsible section in markdown.

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux
@moneal
moneal / firebase_pre-request_script.js
Created August 23, 2017 02:21
Postman pre-request script to create a Firebase authentication JWT header.
/**
* This script expects the global variables 'refresh_token' and 'firebase_api_key' to be set. 'firebase_api_key' can be found
* in the Firebase console under project settings then 'Web API Key'.
* 'refresh_token' as to be gathered from watching the network requests to https://securetoken.googleapis.com/v1/token from
* your Firebase app, look for the formdata values
*
* If all the data is found it makes a request to get a new token and sets a 'auth_jwt' environment variable and updates the
* global 'refresh_token'.
*
* Requests that need authentication should have a header with a key of 'Authentication' and value of '{{auth_jwt}}'