Skip to content

Instantly share code, notes, and snippets.

View princed's full-sized avatar

Eugene Datsky princed

View GitHub Profile
@rcy
rcy / rehash.sh
Created August 29, 2020 18:02
Recompute hashes for graphile-migrate migration files
#!/bin/bash
#
# usage: rehash.sh committed/*.sql
#
# This will update each file's Previous and Hash values
#
function sum {
sha1sum | cut -d' ' -f1
}
<!--
Put this file in ~/Library/LaunchAgents/com.example.KeyRemapping.plist to
automatically remap your keys when macOS starts.
See https://developer.apple.com/library/archive/technotes/tn2450/_index.html for
the key "usage IDs". Take the usage ID and add 0x700000000 to it before putting it
into a source or destination (HIDKeyboardModifierMappingSrc and
HIDKeyboardModifierMappingDst respectively).
-->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
@wchargin
wchargin / multiplyFloat.js
Created April 13, 2020 04:24
multiply bigint by float in JS (spoiler alert: BigInt has no useful functions)
/**
* For a finite normal 64-bit float `f`, extracts integers `sgn`,
* `exponent`, and `mantissa` such that:
*
* - `sgn` is -1 or +1
* - `exponent` is between -1023 and 1024, inclusive
* - `mantissa` is between 0 and 2^51 - 1, inclusive
* - the number given by `f` equals `sgn * 2^exponent * (1 + mantissa / 2^52)`
*
* The results are all bigints within the range of safe integers for
@jesstelford
jesstelford / 01-shape-up-to-kindle.md
Last active January 10, 2024 20:08
Read SHAPE UP by basecamp on a Kindle / reMarkable / eReader

Read Shape Up by basecamp on a kindle / reMarkable / eReader

Basecamp's new book Shape Up is now available online (https://basecamp.com/shapeup) to read page-by-page.

There is a .pdf version, but that's not the best format for Kindle / other eReaders. Instead, we can convert the page-by-page into an eReader friendly format.

Part 1: Convert to a single page

NOTE: This has only been tested on Chrome

option_settings:
- namespace: aws:elasticbeanstalk:cloudwatch:logs
option_name: StreamLogs
value: true
- namespace: aws:elasticbeanstalk:cloudwatch:logs
option_name: DeleteOnTerminate
value: false
- namespace: aws:elasticbeanstalk:cloudwatch:logs
option_name: RetentionInDays
value: 14
@Envek
Envek / rescue-from-git-push-force.md
Last active April 16, 2024 10:12
Откат ошибочной команды git push --force

Откат ошибочной команды git push --force

Иногда при работе с несколькими удалёнными репозиториями в git, может произойти страшное: git push --force в не тот remote и/или не в ту ветку.

Такое может случиться, например, если вы используете [Deis], в котором деплой запускается при git push нужного коммита в сборщик, когда при отладке деплоя после очередного git commit --amend по запарке вместо git push deis master --force делается просто git push --force. Упс.

Как результат, последние коммиты коллег безвозвратно потеряны, и вы чувствуете неотвратимость их ярости…

Но это git, а значит всё можно починить!

@WebReflection
WebReflection / benchmark-dom-classes.js
Last active November 13, 2021 20:52
Classes VS DOM Events Handling Benchmark
// Players
class ClickCounter {
constructor() { this.clicks = 0; }
onclick(e) { this.clicks += (e.type === 'click') ? 1 : -1; }
}
class Handler extends ClickCounter {
constructor(currentTarget) {
super();
currentTarget.addEventListener('click', this);
@rushimusmaximus
rushimusmaximus / youtrack-notify-slack.js
Last active April 28, 2020 08:23
YouTrack JavaScript Workflow example: Post to Slack on specific issue state changes
var entities = require('v1/entities');
var http = require('v1/http');
exports.rule = entities.Issue.onChange({
title: 'Notify-slack',
action: function(ctx) {
var issue = ctx.issue;
if (issue.becomesReported || issue.becomesResolved || issue.becomesUnresolved) {
@dorner
dorner / cron.yaml
Last active July 13, 2023 07:50
How to execute code in Elastic Beanstalk only if you're the leader
# We are not using this file to run actual cron jobs. This is because the
# built-in Elastic Beanstalk cron feature actually puts the jobs at the end
# of the SQS queue. Instead we will run them manually. However, we need to
# have a non-empty cron.yaml or the SQS daemon won't even run and leader
# election won't work.
version: 1
cron:
- name: "DoNothingJob"
url: "/periodic_tasks"
schedule: "0 0 31 2 *"
class Boundary extends Component {
constructor(props) {
super(props);
this.state = { err: null };
}
unstable_handleError(err) {
report(err);
this.setState({ err })
}