Skip to content

Instantly share code, notes, and snippets.

View alexsasharegan's full-sized avatar

Alex Regan alexsasharegan

View GitHub Profile
@alexsasharegan
alexsasharegan / .htaccess
Created September 7, 2016 00:36
Apache Config for React Router
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
@alexsasharegan
alexsasharegan / flexbox.css
Last active December 15, 2023 16:32
Some helpful classes to start using flexbox in your styles. Classes are vendor prefixed, and set up to add one property only—this enables building up styles with class composition. The flexbox class names help convey how the css property will affect your html.
.flex {
display : -webkit-box;
display : -ms-flexbox;
display : flex;
}
.flex-row {
display : -webkit-box;
display : -ms-flexbox;
#!/usr/bin/env bash
dlurl=https://dl.pstmn.io/download/latest/linux64
wget $dlurl -O postman.tar.gz
sudo tar -xzf postman.tar.gz -C /opt
rm postman.tar.gz
sudo ln -s /opt/Postman/Postman /usr/bin/postman
sudo cat > /usr/share/applications/postman.desktop <<EOL
[Desktop Entry]
Encoding=UTF-8
@alexsasharegan
alexsasharegan / wrapErr.ts
Created January 25, 2018 17:26
Go-like error handling with Typescript.
export async function wrapErr<T>(p: Promise<T>): Promise<[any, T | undefined]> {
try {
return [undefined, await p];
} catch (err) {
return [err, undefined];
}
}
let [err, value] = await wrapErr(somePromiseFunc());
if (err) {
@alexsasharegan
alexsasharegan / webpack.config.js
Created May 24, 2017 14:51
Webpack config for vue.js with code splitting and css extracted.
const path = require('path')
const webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin')
const extractStyles = new ExtractTextPlugin({
filename: "css/[name].css"
})
@alexsasharegan
alexsasharegan / waitgroup.ts
Last active April 1, 2020 08:58
Nodejs implementation of the Golang waitgroup.
import { EventEmitter } from "events"
export class WaitGroup extends EventEmitter {
public state: number
constructor(initialState: number = 0) {
if (initialState < 0) {
throw new RangeError()
}
super()
@alexsasharegan
alexsasharegan / recovery.sh
Created February 10, 2020 16:36
System76 recovery script for nvidia errors.
sudo cryptsetup luksOpen /dev/nvme0n1p3 cryptdata
sudo lvscan
sudo vgchange -ay
sudo mount /dev/mapper/data-root /mnt
sudo mount /dev/nvme0n1p1 /mnt/boot/efi
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
sudo cp /etc/resolv.conf /mnt/etc/
sudo chroot /mnt
@alexsasharegan
alexsasharegan / WrappedError.ts
Created January 3, 2020 17:51
Wrap errors using a linked list. Error burritos 🌯
export class WrappedError<ErrKind = any> extends Error implements Iterable<WrappedError | ErrKind> {
previous: ErrKind | null = null;
guid: Guid;
constructor(message: string, previous?: ErrKind) {
super(message);
// We update the error's name to distinguish it from the base Error.
this.name = this.constructor.name;
this.guid = `<${this.name}:empty>`;
// We add our reference to the original error value (if provided).
/**
* Creates a mapped type from the `Subject`
* that excludes all members with types
* that extend the `ExcludeType`.
*/
type ExcludeBy<Subject, ExcludeType> = {
[P in {
[K in keyof Subject]: Subject[K] extends ExcludeType ? never : K
}[keyof Subject]]: Subject[P]
};
Screen 0: minimum 8 x 8, current 5760 x 2160, maximum 32767 x 32767
HDMI-0 disconnected (normal left inverted right x axis y axis)
DP-0 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)
DP-2 connected primary 3840x2160+0+0 (normal left inverted right x axis y axis) 597mm x 336mm
3840x2160 60.00*+ 29.98
2560x1440 59.95
1920x1200 59.88
1920x1080 60.00 59.94 50.00 23.98
1680x1050 59.95