Skip to content

Instantly share code, notes, and snippets.

View josiahwiebe's full-sized avatar

Josiah Wiebe josiahwiebe

View GitHub Profile
@koush
koush / .bash_profile
Last active February 23, 2022 23:54
Put this in your .bash_profile(s) to open VS Code on your local machine while SSH'd into a remote machine.
# this needs to be on the *remote* machine.
if [ ! -z "$SSH_CLIENT" ]
then
function code() {
local ssh_client_host=$(echo $SSH_CLIENT | cut -d ' ' -f1)
if [ -z "$1" ]
then
local argpath="."
@tannerlinsley
tannerlinsley / README.md
Last active April 12, 2024 17:04
Replacing Create React App with the Next.js CLI

Replacing Create React App with the Next.js CLI

How dare you make a jab at Create React App!?

Firstly, Create React App is good. But it's a very rigid CLI, primarily designed for projects that require very little to no configuration. This makes it great for beginners and simple projects but unfortunately, this means that it's pretty non-extensible. Despite the involvement from big names and a ton of great devs, it has left me wanting a much better developer experience with a lot more polish when it comes to hot reloading, babel configuration, webpack configuration, etc. It's definitely simple and good, but not amazing.

Now, compare that experience to Next.js which for starters has a much larger team behind it provided by a world-class company (Vercel) who are all financially dedicated to making it the best DX you could imagine to build any React application. Next.js is the 💣-diggity. It has amazing docs, great support, can grow with your requirements into SSR or static site generation, etc.

So why

@taniarascia
taniarascia / auth.md
Last active February 11, 2024 23:16
JavaScript Authentication & Authorization Book/Course

Authentication in Real-World Web Apps with JavaScript

Outline of ideas, concepts to cover, potential projects to write.

Setup Idea

  • Book with a video for each chapter.

Prerequisites/Overview

// this is a big array of 76 items I need to split into groups of 10
const hugeArray = Array.from({ length: 76 }, (_, i) => i);
function chunkify(array, chunkSize = 10) {
// make a new array
const chunks = Array.from(
// give it however many slots are needed - in our case 8
// 1-7 with 10 items, and 8th slot will have 6
{ length: Math.ceil(array.length / chunkSize) },
// this is a map function that will fill up our slots
# This is a blocklist to block samsung smart tv's sending meta data at home.
# Please help to collect domains!
# It could be that the TV does not receive any more updates or other services no longer work. Please report such an incident.
abtauthprd.samsungcloudsolution.com
acr0.samsungcloudsolution.com
ad.samsungadhub.com
ads.samsungads.com
amauthprd.samsungcloudsolution.com
api-hub.samsungyosemite.com

Fixing macOS 10.14, 10.15, 12

Dark main menu without the rest of dark mode

  1. Set Light mode
  2. defaults write -g NSRequiresAquaSystemAppearance -bool Yes
  3. Log out and log back in
  4. Set Dark mode

gif-from-tweet

There are so many great GIFs out there and I want to have copies of them. Twitter makes that harder than it should be by converting them to MP4 and not providing access to the source material. To make it easier, I made a bash pipeline that takes a tweet URL and a filename, extracts the MP4 from that tweet and uses ffmpeg to convert back to GIF.

Dependencies

  • ffmpeg
    • macOS: brew install ffmpeg
    • Ubuntu/Debian: apt install ffmpeg
@tanaikech
tanaikech / submit.md
Last active February 1, 2024 00:05
Uploading Files to OneDrive Using Node.js

In order to use this script, please retrieve client id, client secret and refresh token before. About this, you can see the detail information at https://gist.github.com/tanaikech/d9674f0ead7e3320c5e3184f5d1b05cc.

1. Simple item upload

This is for the simple item upload is available for items with less than 4 MB of content. The detail information is https://dev.onedrive.com/items/upload_put.htm.

var fs = require('fs');
var mime = require('mime');
var request = require('request');
@lqt0223
lqt0223 / knapsack.js
Created April 11, 2017 11:52
20 0-1 Knapsack problem in JavaScript
/* 0-1 knapsack problem
For an overall introduction to knapsack problem, see https://en.wikipedia.org/wiki/Knapsack_problem
Function name: knapsack
Param:
items: an array of {w: v:} (where 'w' stands for weight, and 'v' stands for value)
capacity: a positive integer number
Will return max sum value that can reach, and the chosen subset to add up to the value.
@wesbos
wesbos / async-await.js
Created February 22, 2017 14:02
Simple Async/Await Example
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works
const axios = require('axios'); // promised based requests - like fetch()
function getCoffee() {
return new Promise(resolve => {
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee
});
}