Skip to content

Instantly share code, notes, and snippets.

@jonbarlo
jonbarlo / README.md
Last active September 17, 2023 16:47
How to build rails API w/JWT auth

README

Rails API using JWT as auth framework this will have user with roles

Things we will cover:

  • Project generation

    create a new Rails API-only application

    rails new rails-jwt-api-sample --api

@Kwisses
Kwisses / MergeSortTutorial.java
Created October 23, 2017 04:52
MergeSortTutorial - [Java]
package mergesort;
class MergeSortTutorial {
// Helper method to print out the integer array.
private static void printArray(int[] array) {
for(int i: array) {
System.out.print(i + " ");
}
@vasanthk
vasanthk / System Design.md
Last active March 13, 2026 10:40
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
// Using the JavaScript language, have the function RunLength(str) take the str parameter being passed and return a compressed // version of the string using the Run-length encoding algorithm. This algorithm works by taking the occurrence of each
// repeating character and outputting that number along with a single character of the repeating sequence.
// For example: "wwwggopp" would return 3w2g1o2p. The string will not contain any numbers, punctuation, or symbols.
// Input = "aabbcde" Output = "2a2b1c1d1e"
// Input = "wwwbbbw" Output = "3w3b1w"
function RunLength( str ) {
var output = '';
while ( str.length > 0 ) {
@furf
furf / makeChange.js
Last active June 17, 2021 13:12
Given a set of coin denominators, find the minimum number of coins to give a certain amount of change.
function makeChange (amount) {
var change = {},
i = 0,
coins = makeChange.COINS,
coin;
while (amount && (coin = coins[i++])) {
if (amount >= coin) {
change[coin] = ~~(amount / coin);
@robbiet480
robbiet480 / bookmarklet.js
Created February 5, 2013 02:40
Reveal Password bookmarklet
javascript:(function()%7Bvar%20IN%20=%20document.getElementsByTagName(%22input%22);for(var%20i=0;%20i<IN.length;%20++i)%7BF%20=%20IN%5Bi%5D;if%20(F.type.toLowerCase()%20==%20%22password%22)%7Bif(document.all)%7Bvar%20n%20=%20document.createElement(%22input%22);for(var%20k%20in%20F.attributes)%20if(k.toLowerCase()%20!=%20'type')%7Btry%7Bn%5Bk%5D%20=%20F%5Bk%5D%7Dcatch(err)%7B%7D%7D;F.parentNode.replaceChild(n,F);%7Delse%7BF.type=%22text%22%7D%7D%7D%7D)()