- Instal Deno. It's a secure runtime for JavaScript and TypeScript.
- Generate a personal access token for GitHub. And save it to
~/.github-oauth
. You can use the following command to save it:echo generated_github_personal_access_token_goes_here > ~/.github-oauth
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ! deno run -A shuffle.ts | |
// Shuffle and group lines in a text file. | |
// Groups are created by adding two newlines between each group. | |
const filename = 'items.txt' | |
const txt = Deno.readTextFileSync(filename) | |
const nonEmpty = (i: string) => i.trim() !== '' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* usbreset -- send a USB port reset to a USB device | |
* | |
* Compile using: gcc -o usbreset usbreset.c | |
* | |
* */ | |
#include <stdio.h> | |
#include <unistd.h> | |
#include <fcntl.h> | |
#include <errno.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Automatically update Cloudflare DNS record when the server IP has changed. | |
# | |
# 1. Update params below | |
# | |
# 2. Add execute permissions: | |
# chmod +x ./update-dns-record.sh | |
# | |
# 3. To run every hour with cron edit crontab file: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"], | |
"rules": { | |
"object-literal-sort-keys": false, | |
"ordered-imports": false, | |
"interface-name": false | |
}, | |
"linterOptions": { | |
"exclude": ["config/**/*.js", "node_modules/**/*.ts"] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Remap section sign key (§) to ESC | |
# | |
# 0x700000064 - section sign (§) key below ESC | |
# 0x700000029 - ESC | |
# | |
# https://developer.apple.com/library/content/technotes/tn2450/_index.html | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const timerFormatter = (secs: number): string => { | |
const secondsInDay = 60 * 60 * 24 | |
const secondsInHour = 60 * 60 | |
const secondsInMinute = 60 | |
const hoursInDay = 24 | |
const days = Math.floor(secs / secondsInDay) | |
const hours = Math.floor((secs / secondsInHour) % hoursInDay).toString().padStart(2, 0) | |
const minutes = Math.floor((secs / secondsInMinute) % secondsInMinute).toString().padStart(2, 0) | |
const seconds = (secs % secondsInMinute).toString().padStart(2, 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UIViewController+VisibleViewController.swift | |
// | |
import Foundation | |
extension UIViewController { | |
func currentlyDisplayedViewController() -> UIViewController? { | |
if isKind(of: UINavigationController.self) { | |
let navigationController = self as! UINavigationController |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// VisibilityToggler+UIView.swift | |
// | |
private var associatedPropertyHeight: CGFloat = 0 | |
private var associatedPropertyWidth: CGFloat = 0 | |
extension UIView { | |
fileprivate var visibilityConstraintIdentifier: String { return "UIVisibilityGenerated" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Resize+UIView.swift | |
// | |
extension UIView { | |
func resizeX(_ width: CGFloat) { | |
for constraint in self.constraints { | |
if constraint.firstAttribute == NSLayoutAttribute.width && constraint.constant != width { | |
constraint.constant = width | |
superview?.layoutIfNeeded() |
NewerOlder