Skip to content

Instantly share code, notes, and snippets.

View Justintime50's full-sized avatar

Justin Hammond Justintime50

View GitHub Profile
@sindresorhus
sindresorhus / esm-package.md
Last active April 18, 2024 06:02
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@metafloor
metafloor / zpl-quick-reference.md
Last active March 6, 2024 00:09
ZPL Quick Reference

ZPL Commands

Command Format Description
^A ^Afo,h,w,d:f.x Use Scalable/Bitmapped Font
^A@ ^A@o,h,w,d:f.x Use Font Name to Call Font
^B0 ^B0a,b,c,d,e,f,g Aztec Bar Code Parameters
^B1 ^B1o,e,h,f,g Code 11 Bar Code
^B2 ^B2o,h,f,g,e,j Interleaved 2 of 5 Bar Code
^B3 ^B3o,e,h,f,g Code 39 Bar Code
@edthrn
edthrn / 1-Unit-testing with PyGithub.md
Last active October 19, 2023 05:09
Unit-testing with PyGithub

Intro

Lately, I've been building a Python platform that relies heavily on interactions with Github. Instead of re-inventing the wheel, I decided to go with PyGithub as a wrapper around Github v3 API.

The problem

This library implements the full API, which allows me to be very productive when I need to add a workflow in my platform that involves Github. However, it quickly became a real PITA to write unit tests. Even if the package comes with its own testing Framework, it is not documented yet and I didn't manage to crack it up in a decent amount of time.

I decided to hack the testing a little bit, using another very cool package, httpretty. Httpretty allows you to monkey patch the socket module during testing, so you can respond anything you want to any kind of network requests. Here's what I came up with, do not hesitate to give any feedback.


@tmsnvd
tmsnvd / ruleset.md
Last active February 28, 2024 07:27
phpcs PHP_CodeSniffer rules list
Rule Namespace Description
Arrays.ArrayBracketSpacing /Squiz.Arrays.ArrayBracketSpacing Ensure that there are no spaces around square brackets.
Arrays.ArrayDeclaration /Squiz.Arrays.ArrayDeclaration Ensures that arrays conform to the array coding standard.
Arrays.DisallowLongArraySyntax /Generic.Arrays.DisallowLongArraySyntax Bans the use of the PHP long array syntax.
Arrays.DisallowShortArraySyntax /Generic.Arrays.DisallowShortArraySyntax Bans the use of the PHP short array syntax.
CSS.BrowserSpecificStyles /MySource.CSS.BrowserSpecificStyles Ensure that browser-specific styles are not used.
CSS.ClassDefinitionClosingBraceSpace /Squiz.CSS.ClassDefinitionClosingBraceSpace Ensure there is a single blank line after the closing brace of a class definition.
CSS.ClassDefinitionNameSpacing /Squiz.CSS.ClassDefinitionNameSpacing Ensure there are no blank lines between the names of classes/IDs.
CSS.ClassDefinitionOpeningBrace
@nickbclifford
nickbclifford / auto-deploying.md
Last active May 15, 2023 09:02
How to automatically deploy code to a server using Travis CI

Auto-Deploying via Travis CI

Because Travis CI can automatically execute scripts after successfully (or unsuccessfully!) executing tests, it is an obvious choice for a deployment tool. In order to deploy to a Git repository on a remote server, the process generally is as follows:

  • Set up SSH keys
  • Add the server's copy of the repository as a Git remote
  • Push to the remote
  • SSH into the server and execute any installation/compilation/miscellaneous commands

Before even touching .travis.yml...

Users

@asukakenji
asukakenji / 0-go-os-arch.md
Last active April 9, 2024 18:54
Go (Golang) GOOS and GOARCH

Go (Golang) GOOS and GOARCH

All of the following information is based on go version go1.17.1 darwin/amd64.

GOOS Values

GOOS Out of the Box
aix
android
@benjamincharity
benjamincharity / autonomous.txt
Last active April 12, 2024 22:20
Instructions on how to reset the autonomous desk. This fixes a problem where the desk will not lower (also reportedly fixes incorrectly reported heights).
> Thank you for reaching out to Autonomous! I am sorry to hear that you are having some trouble with your SmartDesk
> but I will be glad to assist. It sounds like your system needs a "hard reset" can I please have you follow these
> steps thoroughly.
Reset Steps:
1. Unplug the desk for 20 seconds. Plug it back in. Wait a full 20 seconds.
2. Press the up and down buttons until the desk lowers all the way and beeps or 20 seconds pass.
3. Release both buttons.
4. Press the down buttons until the desk beeps one more time or 20 seconds pass.
@wolph
wolph / update_wan_ip.rsc
Created March 25, 2017 16:37
Mikrotik script to detect WAN IP updates and call scripts if it changes.
:global wanInterface "wan1"
:global wanIP "$wanIP"
# Get the current IP on the interface
:local currentIPtemp [/ip address get [find interface="$wanInterface" disabled=no] address];
# IP without netmask
:local currentIP [:pick $currentIPtemp 0 ([:len $currentIPtemp]-3)];
:if ($currentIP != $wanIP) do={
@jamesbar2
jamesbar2 / postal-codes.json
Last active April 17, 2024 17:40 — forked from matthewbednarski/postal-codes.json
Global postal codes regex formats
[{
"Note": "The first two digits (ranging from 10–43) correspond to the province, while the last two digits correspond either to the city/delivery zone (range 01–50) or to the district/delivery zone (range 51–99). Afghanistan Postal code lookup",
"Country": "Afghanistan",
"ISO": "AF",
"Format": "NNNN",
"Regex": "^\\d{4}$"
}, {
"Note": "With Finland, first two numbers are 22.",
"Country": "Åland Islands",
"ISO": "AX",
@ammario
ammario / goth
Created September 2, 2016 16:27
golang test coverage html
#!/bin/bash
go test -coverprofile=coverage.out
go tool cover -html=coverage.out