Skip to content

Instantly share code, notes, and snippets.

@fliedonion
fliedonion / !GIST file list order - summary.md
Last active April 26, 2024 08:11
Understand GIST file list order.
Summary How to control (or Understand) your GIST page's files list order.
Notice not official documentation.
@BrianWill
BrianWill / Javascript - asynchronous code.md
Last active April 26, 2024 08:11
Using asynchronous API's using callbacks and Promises

In most programming languages, most functions are synchronous: a call to the function does all of its business in the same thread of execution. For functions meant to retrieve data, this means the data can be returned by calls to the function.

For an asynchronous function, a call to the function triggers business in some other thread, and that business (usually) does not complete until after the call returns. An asynchronous function that retrieves data via another thread cannot directly return the data to the caller because the data is not necessarily ready by the time the function returns.

In a sense, asynchronous functions are infectious: if a function foo calls an asynchronous function to conclude its business, then foo itself is asynchronous. Once you rely upon an asynchronous function to do your work, you cannot somehow remove the asynchronicity.

callbacks

When the business initiated by an asynchronous function completes, we may want to run some code in response, so the code run

@groue
groue / ObservableState.swift
Last active April 26, 2024 08:11
WithBindable
import SwiftUI
/// Supplies an observable object to a view’s hierarchy.
///
/// The purpose of `WithBindable` is to make it possible to instantiate
/// observable objects from environment values, while keeping the object
/// alive as long as the view is rendered.
///
/// For example:
///
@steve981cr
steve981cr / How-to-Release-an-Electron-App-on-the-Mac-App-Store.md
Last active April 26, 2024 08:10
Step by step instructions on how to release an Electron app on the Mac App Store. Uses Electron-builder to package the app.
@er-abhishek-luthra
er-abhishek-luthra / DetectPhoneCallState.md
Last active April 26, 2024 08:10
DetectPhoneCallState.md

PhoneCallReceiver

Due to the design of Android, PhoneCallReceiver have to be a BroadcastReceiver. It can’t be a reciever registered with one app because the receiver may be run without our app being run, so we’d have to register in manifest. But I want the heavy lifting to be done by a library class(which we will be creating below)- I just want to derive from something and override a few functions. So ideally we have something like:

public abstract class PhonecallReceiver extends BroadcastReceiver {
protected void onIncomingCallStarted(Context ctx, String number, Date start);
protected void onOutgoingCallStarted(Context ctx, String number, Date start);

Writing Functionally Pure Code

Is all my code going to be pure?

Nope. No program can be composed 100% of pure code because every program must do I/O work, which is inherently stateful. Most programs also need to carry around some amount of internal state, to one degree or another. The goal of functional programming, then, is to maximize the proportion of pure code to impure code in your program.

Pure vs. Impure

What does it mean for data and code to be pure? The short answer is that pure things are immutable, but this is not quite accurate: all pure things are immutable, but not all immutable things are pure. Pure things are not only unmodifiable but also definitional.

@bnadlerjr
bnadlerjr / tmpl.js
Created February 26, 2012 03:43
A simple templating solution using <code>with(){}</code> for simplified templates. Taken from "Secrets of the JavaScript Ninja.
// A simple templating solution using <code>with(){}</code> for simplified templates.
// Taken from "Secrets of the JavaScript Ninja.
(function(){
var cache = {};
this.tmpl = function tmpl(str, data){
// Figure out if we're getting a template, or if we need to
// load the template - and be sure to cache the result.
var fn = !/\W/.test(str) ?
cache[str] = cache[str] ||
tmpl(document.getElementById(str).innerHTML) :
@jumski
jumski / setup.md
Created January 21, 2019 16:15 — forked from jdesive/setup.md
Mount NFS share from synology NAS to Ubuntu

Mount Synology NFS share to Ubuntu 16.04

I have all hardware virtualized in ESXi 6.5...
Synology DSM 5.2-5644
Ubuntu 16.04

Start

On your fresh install on Ubuntu 16.04:

  1. Click the Connections icon on the top bar
  2. Goto Edit Connections
@onselakin
onselakin / tf-module.md
Created March 18, 2023 12:10
Creating a Terraform module with Jarvis (ChatGPT)

Azure Blob Storage Config.

Started on: 3/18/2023, 10:33:07 AM


Önsel:

Let's create a terraform config for Azure. Give me a terraform code for creating a secure blob storage first.

Jarvis: