Skip to content

Instantly share code, notes, and snippets.

View Sija's full-sized avatar
⚡

Sijawusz Pur Rahnama Sija

⚡
View GitHub Profile
@DOBRO
DOBRO / UCI-Protocol-Specification.txt
Last active October 1, 2026 11:27
Description of the Universal Chess Interface (UCI)
// Dowloaded from: http://download.shredderchess.com/div/uci.zip
Description of the universal chess interface (UCI) April 2006
=================================================================
* The specification is independent of the operating system. For Windows,
the engine is a normal exe file, either a console or "real" windows application.
* all communication is done via standard input and output with text commands,
@abrom
abrom / config.ru
Last active March 30, 2022 07:43
Address CVE-2015-9284 for generic Rack apps (eg Sinatra) for Omniauth
require 'omniauth/strategies/<your strategy>'
require_relative 'omniauth_authenticity_checker'
OmniAuth.config.allowed_request_methods = [:post]
OmniAuth.config.before_request_phase = OmniauthAuthenticityChecker.new(reaction: :drop_session)
# And if you haven't already, you should be loading in the `Rack::Protection` middleware:
use Rack::Protection, reaction: :drop_session, use: :authenticity_token
@Birch-san
Birch-san / make_portable.sh
Last active October 2, 2025 10:28
Make a macOS executable binary or .dylib portable
#!/usr/bin/env bash
# Licensed by author Alex Birch under CC BY-SA 4.0
# https://creativecommons.org/licenses/by-sa/4.0/
# Example input:
# ./make_portable.sh mycoolbinary
# where mycoolbinary is a mach-o object file
# (for example an executable binary or a .dylib)
#
@straight-shoota
straight-shoota / install-crystal-nightly.sh
Last active May 5, 2020 21:39
install-crystal-nightly.sh
#! /usr/bin/env bash
#
# This script looks up the latest successfull nightly build of crystal on
# Circle CI, extracts the build number of `dist_artifacts` job and retrieves
# it's artifacts list.
#
# From this artifacts list, the specified tar package is downloaded and
# extracted in $INSTALL_DIR.
# The binaries `bin/crystal` and `bin/shards` are linked as `crystal-nightly`
# and `shards-nightly` in `/usr/local/bin`.
@soulmachine
soulmachine / jwt-expiration.md
Last active May 3, 2026 13:29
How to deal with JWT expiration?

First of all, please note that token expiration and revoking are two different things.

  1. Expiration only happens for web apps, not for native mobile apps, because native apps never expire.
  2. Revoking only happens when (1) uses click the logout button on the website or native Apps;(2) users reset their passwords; (3) users revoke their tokens explicitly in the administration panel.

1. How to hadle JWT expiration

A JWT token that never expires is dangerous if the token is stolen then someone can always access the user's data.

Quoted from JWT RFC:

@gkaemmer
gkaemmer / Elixir_Supervision_Trees.md
Last active December 18, 2023 14:37
Quick guide to creating Elixir supervision trees from scratch

Elixir Supervision Trees Made Easy

I started with Elixir just a couple weeks after the switch from 1.4 to 1.5, so the bulk of online resources were out of date (or at least resulted in deprecation warnings). This guide is for defining Elixir 1.5 supervised modules.

It's not actually terribly complicated. It's just sometimes unclear from examples what's implemented by the language and what you actually have to implement yourself.

Say we want a supervision tree like this (where each atom is a process):

    :a

/ \

@teamon
teamon / box.ex
Created August 25, 2017 23:09
Define elixir structs with typespec with single line of code
defmodule Box do
defmacro __using__(_env) do
quote do
import Box
end
end
@doc """
Define module with struct and typespec, in single line
@JohnSundell
JohnSundell / AnyOf.swift
Created August 21, 2017 21:23
A way to easily compare a given value against an array of candidates
import Foundation
struct EquatableValueSequence<T: Equatable> {
static func ==(lhs: EquatableValueSequence<T>, rhs: T) -> Bool {
return lhs.values.contains(rhs)
}
static func ==(lhs: T, rhs: EquatableValueSequence<T>) -> Bool {
return rhs == lhs
}
@xerub
xerub / sepsplit.c
Last active September 21, 2026 03:38
/*
* SEP firmware split tool
*
* Copyright (c) 2017 xerub
*/
#include <fcntl.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
@ziprandom
ziprandom / type_hierarchy_macros.cr
Last active May 3, 2017 13:47
Nesting & Reusing Crystal Macros to Build Up Class Constans Along the Type Hierarchy
require "spec"
macro on_all_child_classes(&block)
macro injection
{{block && block.body}}
end
macro inject
injection
macro inherited
injection