Skip to content

Instantly share code, notes, and snippets.

View tlkahn's full-sized avatar
🥫

Leo tlkahn

🥫
View GitHub Profile
@avosalmon
avosalmon / firebase_token.rb
Last active June 3, 2024 00:04
Verify Firebase auth JWT token
require 'base64'
require 'httparty'
require 'jwt'
class FirebaseToken
JWT_ALGORITHM = 'RS256'.freeze
PUBLIC_KEY_URL = 'https://www.googleapis.com/robot/v1/metadata/x509/securetoken@system.gserviceaccount.com'.freeze
def initialize(token)
@token = token
@edouardpineau
edouardpineau / iterators.ipynb
Last active September 22, 2022 01:56
Python workshop iterators
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vedantroy
vedantroy / client.cpp
Last active April 8, 2024 22:26
A C++ Client That Sends Data Over TLS Using OpenSSL
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <resolv.h>
#include <netdb.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
//Not sure what headers are needed or not
//This code (theoretically) writes "Hello World, 123" to a socket over a secure TLS connection
@johntran
johntran / es7AsyncAwaitParallel.js
Last active September 22, 2020 18:54
ES7 multiple async/await functions in parallel execution.
//old: productReviews.js - lines 121 - 125
async function productReviewsByProductAllGet(request, response) {
try {
const { productId } = request.params;
// get all reviews for a product id
const reviews = await productReviewsQuery.selectAllByProductId(productId);
const result = [];
// Loop from beginning of reviews array to reviews
for(let i = 0; i < reviews.length; i++) {
@davegurnell
davegurnell / TypeclassDemo.scala
Created October 6, 2015 14:53
Example of the type class pattern in Scala
object TypeclasseDemo {
// The parts of the type class pattern are:
//
// 1. the "type class" itself -- a trait with a single type parameter;
//
// 2. type class "instances" for each type we care about,
// each marked with the `implicit` keyword;
//
// 3. an "interface" to the type class -- one or more methods
@rioshen
rioshen / Backtrack.java
Created September 24, 2014 00:25
Backtracking Template
public class Backtrack {
public static List<List<Object>> backtrack(int[] A) {
// Set up a list of list to hold all possible solutions
List<List<Object>> result = new LinkedList<List<Object>>();
if (A == null || A.length == 0) {
return result;
}
// As we need to recursively generate every solution,
// a variable is needed to store single solution.
@n8henrie
n8henrie / txt_to_reminders.applescript
Last active March 11, 2024 17:04
Demonstration of using AppleScript with Reminders.app
--taken from http://benguild.com/2012/04/11/how-to-import-tasks-to-do-items-into-ios-reminders/#comment-1346894559
--set theFileContents to (read file "Users:n8henrie:Desktop:Reminders.txt") -- Change this to the path to your downloaded text file with your tasks in it! (Note the : instead of a / between folders) Or, just name them Reminders.txt and put them in your downloads folder
--set theLines to paragraphs of theFileContents
set theLines to {"task name 1", "task name 2"}
repeat with eachLine in theLines
tell application "Reminders"
set mylist to list "Your List Name"
tell mylist
make new reminder at end with properties {name:eachLine, due date:date "7/10/2014 3:00 PM"}