Skip to content

Instantly share code, notes, and snippets.

@sachinnair90
sachinnair90 / skiplist.py
Created January 1, 2018 19:14
Simple Skip list implementation in Python
from random import randint, seed
class Node:
def __init__(self, height = 0, elem = None):
self.elem = elem
self.next = [None]*height
class SkipList:
def __init__(self):
@Leaking
Leaking / find TrustManager From SSLContext
Created December 3, 2017 12:38
find TrustManager From SSLContext
private X509TrustManager findTrustManagerFromSocketFactory(SSLContext mCtx) {
try {
//SSLContext --> contextSpi(OpenSSLContextImpl) --> sslParameters(SSLParametersImpl) --> x509TrustManager(X509TrustManager)
// find OpenSSLContextImpl
Field contextSpiField = mCtx.getClass().getDeclaredField("contextSpi");
contextSpiField.setAccessible(true);
Object openSSLContextImplObj = contextSpiField.get(mCtx);
// find SSLParametersImpl
@crittermike
crittermike / wget.sh
Last active March 28, 2025 18:44
Download an entire website with wget, along with assets.
# One liner
wget --recursive --page-requisites --adjust-extension --span-hosts --convert-links --restrict-file-names=windows --domains yoursite.com --no-parent yoursite.com
# Explained
wget \
--recursive \ # Download the whole site.
--page-requisites \ # Get all assets/elements (CSS/JS/images).
--adjust-extension \ # Save files with .html on the end.
--span-hosts \ # Include necessary assets from offsite as well.
--convert-links \ # Update links to still work in the static version.
class Architects:
def __init__(self, n, constraints):
self.constraints = constraints
self.n = n
def size(self):
return len(self.constraints[0])
def north(self):
return self.constraints[0]
@hughbris
hughbris / README-imgur-api-upload-file-js.md
Last active February 8, 2024 20:00
Javascript Imgur API uploading example using type=file

This Gist shows an otherwise (AFAICT) undocumented way to upload images using the Imgur API with type=file.

I did not want to base64 encode (type=base64) the file contents because my use case was within a Cordova app where resources may limited.

The file is taken from the device file system, so no URL is accessible for file=url.

I was unable to find any guidance or examples in online documentation using this method in Javascript (or any language, AFAIR). I emailed(!) the suggested support contact laying out the problem and stressing that I had not found examples in the documentation. The reply came a month later, pointing me to the very docs in which I had told them I found no satisfactory answer or example! Gee, thanks.

It wasn't too hard, playing with cURL, to get a working call from command line:

@zmts
zmts / tokens.md
Last active May 15, 2025 14:07
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
Below are the Big O performance of common functions of different Java Collections.
List | Add | Remove | Get | Contains | Next | Data Structure
---------------------|------|--------|------|----------|------|---------------
ArrayList | O(1) | O(n) | O(1) | O(n) | O(1) | Array
LinkedList | O(1) | O(1) | O(n) | O(n) | O(1) | Linked List
CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array
@rudelm
rudelm / autofs.md
Last active May 15, 2025 18:50
Use autofs on Mac OS X to mount network shares automatically during access

Autofs on Mac OS X

With autofs you can easily mount network volumes upon first access to the folder where you want to mount the volume. Autofs is available for many OS and is preinstalled on Mac OS X so I show you how I mounted my iTunes library folder using this method.

Prepare autofs to use a separate configuration file

autofs needs to be configured so that it knows where to gets its configuration. Edit the file /etc/auto_master and add the last line:

#
# Automounter master map
#

+auto_master # Use directory service

@reportbase
reportbase / bitly
Created November 10, 2015 00:42
bitly
[0, clr.SUBHEADER, "Bitly User Info", function()
{
var http = new XMLHttpRequest();
http.open("GET", "https://api-ssl.bitly.com/v3/user/info?access_token=" + global.bitfly_access_token);
http.responseType = "json";
http.onreadystatechange = function(){if (this.readyState == this.DONE) console.log(this.response);};
http.send();
}],
[0, clr.SUBHEADER, "Bitly Link Info", function()
@brenes
brenes / instructions
Created June 8, 2015 09:34
Repairing non-monotic index git error
> git fetch
...
error: non-monotonic index .git/objects/pack/pack-be03d54c63e1a503114461d4c1945b34c7af01c8.idx
...
> rm .git/objects/pack/pack-be03d54c63e1a503114461d4c1945b34c7af01c8.idx
> git index-pack .git/objects/pack/pack-be03d54c63e1a503114461d4c1945b34c7af01c8.pack