Skip to content

Instantly share code, notes, and snippets.

View shamrt's full-sized avatar

Shane Martin shamrt

View GitHub Profile
@wbern
wbern / bump-caniuse-lite.js
Last active May 12, 2022 20:27
Update caniuse-lite i pnpm-lock.yaml (mostly for Rush users) - PUT INSIDE `scripts/` IN THE REPO ROOT FOR PATHS TO WORK
#!/bin/node
// Script bumps caniuse-lite in common/config/rush/pnpm-lock.yaml
const path = require("path");
const fs = require("fs");
const { execSync } = require("child_process");
async function main() {
const repoRoot = path.join(__dirname, "../");
@leo6104
leo6104 / ng-update-v6.js
Last active December 21, 2021 00:05
Convert .angular-cli.json to angular.json (for Angular 6 Migration from Angular 2/4/5)
/**
* Created by leo6104 (github.com/leo6104)
* You can use this nodejs script on angular v5/v4/v2 project.
* 1. Place this gist file `ng-update-v6.js` to angular project's root path
* 2. use command `node ng-update-v6.js .angular-cli.json`
* 3. check angular.json file (created by ng-update-v6.js)
**/
const fs = require('fs');
const path = require('path');
/**
* Default configuration to lint
* the airbnb css style-guide.
* This file is taken from a pull request to Airbnb/css repo
* which intends to create a default preset that can be used
* in the future. Until it is merged, we will have the config here.
* https://github.com/airbnb/css/pull/23
* Add more rules: http://stylelint.io/user-guide/rules/
* Also, to understand better who the rules are named:
* http://stylelint.io/user-guide/about-rules/
@jesstelford
jesstelford / event-loop.md
Last active April 28, 2024 06:50
What is the JS Event Loop and Call Stack?

Regular Event Loop

This shows the execution order given JavaScript's Call Stack, Event Loop, and any asynchronous APIs provided in the JS execution environment (in this example; Web APIs in a Browser environment)


Given the code

Automatically Prepend a Jira Issue ID to Git Commit Messages

Use a git hook to match a Jira issue ID from the current branch, and prepend it to every commit message

Assuming the current branch contains a Jira issue ID, you can use a git hook script to prepend it to every commit message.

  1. Create an empty commit-msg git hook file, and make it executable. From your project's root directory:

     install -b -m 755 /dev/null .git/hooks/commit-msg
    
  2. Save the following script to the newly-created .git/hooks/commit-msg file:

@seyDoggy
seyDoggy / SomeCtrl.js
Last active March 4, 2022 16:54
My version of the AngularJS ui-bootstrap alert service as derived from here: https://coderwall.com/p/r_bvhg/angular-ui-bootstrap-alert-service-for-angular-js. No $rootScopes were harmed in the making of this code.
(function () {
'use strict';
angular.module('myApp')
.controller('SomeCtrl', SomeCtrl);
SomeCtrl.$inject = ['$scope', '$http', ' alertService'];
function SomeCtrl($scope, $http, alertService) {
$http.put('http://some.url/user/44', {
#!/bin/bash
PREFIX=$(basename "$1" .pdf)
if [ ! -z "$TESSERACT_FLAGS" ]; then
echo "Picked up TESSERACT_FLAGS: $TESSERACT_FLAGS"
fi
echo "Prefix is: $PREFIX"
echo "Converting to TIFF..."
if command -v parallel >/dev/null 2>&1; then
LAST_PAGE=$(($(pdfinfo "$1"|grep '^Pages:'|awk '{print $2}') - 1))
@Kartones
Kartones / postgres-cheatsheet.md
Last active May 3, 2024 20:51
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@mangecoeur
mangecoeur / concurrent.futures-intro.md
Last active January 9, 2024 16:04
Easy parallel python with concurrent.futures

Easy parallel python with concurrent.futures

As of version 3.3, python includes the very promising concurrent.futures module, with elegant context managers for running tasks concurrently. Thanks to the simple and consistent interface you can use both threads and processes with minimal effort.

For most CPU bound tasks - anything that is heavy number crunching - you want your program to use all the CPUs in your PC. The simplest way to get a CPU bound task to run in parallel is to use the ProcessPoolExecutor, which will create enough sub-processes to keep all your CPUs busy.

We use the context manager thusly:

with concurrent.futures.ProcessPoolExecutor() as executor:
@jlduran
jlduran / article.md
Last active April 4, 2024 04:35
pandoc booktabs minimal template (illustrative purposes only) (See: https://github.com/jgm/pandoc/pull/1076)

How big's your cloud? {-}


                    **Apple**    **Google**   **Microsoft**

Revenue[^1], $bn 34.6 22.3 58.4

Profit[^1], $bn 5.2 4.6 14.6

Market capitalisation 170.2 127.3 230.4