Skip to content

Instantly share code, notes, and snippets.

View tomsiwik's full-sized avatar
🔴
Recording

Tom Siwik tomsiwik

🔴
Recording
View GitHub Profile
@highfestiva
highfestiva / binance-liquidation-calculator.py
Last active April 16, 2024 06:13
CLI Binance liquidation calculation formula
#!/usr/bin/env python3
'''2021-03-26: Reverse-engineer by searching for the following terms in features*.js:
- bracketMaintenanceMarginRate
- cumFastMaintenanceAmount
- bracketNotionalFloor
- bracketNotionalCap'''
# (max) position, maintenance margin, maintenance amount
maint_lookup_table = [
@r17x
r17x / setupTest.md
Last active April 22, 2019 11:34
Setup Test in ReactJs With Jest Enzyme & etc
  • create setupTests.js in src/setupTests.js (automatically CRA read setupTest.js)
// setupTests.js
import React from "react";
import Adapter from "enzyme-adapter-react-16";
import Enzyme, { configure, shallow, mount, render } from "enzyme";
import { createSerializer } from "enzyme-to-json";
import sinon from "sinon";

expect.addSnapshotSerializer(createSerializer({ mode: "deep" }));
@mkuklis
mkuklis / lambda-image-resizer.js
Created July 31, 2018 17:53
AWS Lambda for image resizing with sharp
const sharp = require('sharp');
const aws = require('aws-sdk');
const s3 = new aws.S3();
const Bucket = "BucketName";
const transforms = [
{ name: 'small', size: 85 },
{ name: 'medium', size: 160 },
{ name: 'large', size: 250 },
];
@zish
zish / vpnc-script
Last active June 13, 2022 18:47
OpenConnect vpnc-script for for MacOS High Sierra. Resolves problem with split DNS.
#!/bin/sh
#
# Originally part of vpnc source code:
# © 2005-2012 Maurice Massar, Jörg Mayer, Antonio Borneo et al.
# © 2009-2012 David Woodhouse <dwmw2@infradead.org>
#
# 2018-05-15 - Minor scutil updates for MacOS Split DNS added by Jeremy Melanson ( https://github.com/zish ).
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@milankorsos
milankorsos / redux-actions.ts
Last active November 10, 2022 10:58
Correct TypeScript typing example for Redux Thunk actions
import {Action, ActionCreator, Dispatch} from 'redux';
import {ThunkAction} from 'redux-thunk';
// Redux action
const reduxAction: ActionCreator<Action> = (text: string) => {
return {
type: SET_TEXT,
text
};
};
@eladg
eladg / Heights-shader.frag
Last active November 22, 2022 06:24
WebGL-HeatMap - Shaders in GLSL
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp int;
precision highp float;
#else
precision mediump int;
precision mediump float;
#endif
varying vec2 off, dim;
varying float vIntensity;
@tylerneylon
tylerneylon / .block
Last active September 2, 2023 14:21
Quick js code to draw math functions in an SVG element.
license: mit
@zhiguangwang
zhiguangwang / README.md
Last active August 25, 2023 12:47
Disable and Enable kdc on Mac OS X

If you don't like or need the kdc process on Mac OS X, which opens TCP port 88 to the world, you can disable it with launchctl.

Disable:

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.Kerberos.kdc.plist

Enable:

sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.Kerberos.kdc.plist
@gbaman
gbaman / HowToOTG.md
Last active April 16, 2024 22:39
Simple guide for setting up OTG modes on the Raspberry Pi Zero

Raspberry Pi Zero OTG Mode

Simple guide for setting up OTG modes on the Raspberry Pi Zero - By Andrew Mulholland (gbaman).

The Raspberry Pi Zero (and model A and A+) support USB On The Go, given the processor is connected directly to the USB port, unlike on the B, B+ or Pi 2 B, which goes via a USB hub.
Because of this, if setup to, the Pi can act as a USB slave instead, providing virtual serial (a terminal), virtual ethernet, virtual mass storage device (pendrive) or even other virtual devices like HID, MIDI, or act as a virtual webcam!
It is important to note that, although the model A and A+ can support being a USB slave, they are missing the ID pin (is tied to ground internally) so are unable to dynamically switch between USB master/slave mode. As such, they default to USB master mode. There is no easy way to change this right now.
It is also important to note, that a USB to UART serial adapter is not needed for any of these guides, as may be documented elsewhere across the int

@sebastiandeutsch
sebastiandeutsch / db.py
Created September 21, 2015 11:25
Convert MySQL to Postres
#!/usr/bin/env python
"""
Fixes a MySQL dump made with the right format so it can be directly
imported to a new PostgreSQL database.
Dump using:
mysqldump --compatible=postgresql --default-character-set=utf8 -r databasename.mysql -u root databasename
"""