Skip to content

Instantly share code, notes, and snippets.

@suyash
suyash / Cargo.toml
Last active December 27, 2022 14:51
@karpathy's min-char-rnn.py in rust
[package]
name = "min-char-rnn-rs"
version = "0.1.0"
authors = ["Suyash <[email protected]>"]
edition = "2018"
[dependencies]
rulinalg = "0.4.2"
rand = "0.6.4"
indicatif = "0.11.0"
@danielt1263
danielt1263 / TokenAcquisitionService.swift
Last active August 30, 2024 06:33
The TokenAcquisitionService automatically retry requests if it receives an unauthorized error. Complete with proof that it works correctly.
//
// TokenAcquisitionService.swift
//
// Created by Daniel Tartaglia on 16 Jan 2019.
// Copyright © 2024 Daniel Tartaglia. MIT License.
//
import Foundation
import RxSwift
@mxcl
mxcl / detweet.swift
Last active August 16, 2024 15:38
Delete all tweets and favorites older than two months ago. Instructions in comment.
#!/usr/bin/swift sh
import Foundation
import PromiseKit // @mxcl ~> 6.5
import Swifter // @mattdonnelly == b27a89
let swifter = Swifter(
consumerKey: "FILL",
consumerSecret: "ME",
oauthToken: "IN",
oauthTokenSecret: "https://developer.twitter.com/en/docs/basics/apps/overview.html"
@lukas1
lukas1 / README.md
Last active October 17, 2022 05:44
A swift script that generates Color Assets and a Swift file containing enum of colors based on input json

Call the script like this:

./palette-generator.swift example-input.json

It will create a folder Colors in the folder where this script is executed, containing output.

@josephcsible
josephcsible / unmap_all_syscalls.c
Last active July 17, 2022 16:39
Make it impossible for strace to force a syscall
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/syscall.h>
@fay59
fay59 / Quirks of C.md
Last active April 3, 2025 02:27
Quirks of C

Here's a list of mildly interesting things about the C language that I learned mostly by consuming Clang's ASTs. Although surprises are getting sparser, I might continue to update this document over time.

There are many more mildly interesting features of C++, but the language is literally known for being weird, whereas C is usually considered smaller and simpler, so this is (almost) only about C.

1. Combined type and variable/field declaration, inside a struct scope [https://godbolt.org/g/Rh94Go]

struct foo {
   struct bar {
 int x;
@alexruperez
alexruperez / SiriViewController.swift
Last active November 29, 2018 16:32
Create your own Siri in Swift | Lil ‘Bits | https://www.youtube.com/watch?v=Sigl3dihEB8
import UIKit
import Speech
class SiriViewController: UIViewController {
private static let locale = Locale(identifier: "es-ES")
private let speechRecognizer = SFSpeechRecognizer(locale: SiriViewController.locale)!
private var recognitionRequest: SFSpeechAudioBufferRecognitionRequest?
private var recognitionTask: SFSpeechRecognitionTask?
private let audioEngine = AVAudioEngine()
@mads-hartmann
mads-hartmann / anything-dirty.sh
Created March 20, 2018 19:58
🤖 Tiny script to check if I had any dirty repos or un-pushed branches before sending my MBP to repair.
#!/bin/bash
set -euo pipefail
function is-git-repository {
[[ -d "$1/.git" ]] || (cd "$1" && git rev-parse --git-dir > /dev/null 2>&1)
}
function echo-is-dirty {
cd "$1"
if [[ ! -z $(git status -s) ]]
@mosra
mosra / main.cpp
Last active February 24, 2019 12:20
First Triangle in Vulkan
#include <Corrade/Utility/Assert.h>
#include <Corrade/PluginManager/Manager.h>
#include <Magnum/Magnum.h>
#include <Magnum/ImageView.h>
#include <Magnum/PixelFormat.h>
#include <Magnum/Math/Color.h>
#include <Magnum/Trade/AbstractImageConverter.h>
#include <MagnumExternal/Vulkan/flextVk.h>
#include <MagnumExternal/Vulkan/flextVkGlobal.h>
@gokselkoksal
gokselkoksal / Channel.swift
Last active September 16, 2022 03:53
Channel implementation
public class Channel<Value> {
private class Subscription {
weak var object: AnyObject?
private let notifyBlock: (Value) -> Void
private let queue: DispatchQueue
var isValid: Bool {
return object != nil