Skip to content

Instantly share code, notes, and snippets.

@cowboy
cowboy / abstraction-2020.js
Last active September 24, 2023 12:24
Abstraction.js 2020 Edition (ES6)
/*
* Abstraction.js 2020 Edition
*
* Copyright (c) 2020 "Cowboy" Ben Alman
* Licensed under the MIT license.
* http://benalman.com/about/license/
*/
let $elseif, $else, $if = state => state ? (
$elseif = () => () => {},
@MSny
MSny / NY_DMA_Zip
Created October 13, 2017 18:44
New York DMA Zip Codes Array
["06404","06440","06468","06470","06482","06484","06491","06497","06601","06602","06604","06605","06606","06607","06608","06610","06611","06612","06614","06615","06650","06673","06699","06784","06801","06804","06807","06810","06811","06812","06813","06814","06816","06817","06820","06824","06825","06828","06829","06830","06831","06832","06836","06838","06840","06842","06850","06851","06852","06853","06854","06855","06856","06857","06858","06859","06860","06870","06875","06876","06877","06878","06879","06880","06881","06883","06888","06889","06890","06896","06897","06901","06902","06903","06904","06905","06906","06907","06910","06911","06912","06913","06914","06920","06921","06922","06925","06926","06927","06928","07010","07020","07022","07024","07026","07031","07057","07070","07071","07072","07073","07074","07075","07401","07407","07410","07417","07423","07430","07432","07436","07446","07450","07451","07452","07458","07463","07481","07495","07601","07602","07603","07604","07605","07606","07607","07608","07620"
@gesquive
gesquive / cmd.go
Created April 27, 2017 21:48
Run an external command with golang
// run a command using the shell; no need to split args
// from https://stackoverflow.com/questions/6182369/exec-a-shell-command-in-go
func runcmd(cmd string, shell bool) []byte {
if shell {
out, err := exec.Command("bash", "-c", cmd).Output()
if err != nil {
log.Fatal(err)
panic("some error found")
}
return out
@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
});
}
@benwells
benwells / reduce-example.js
Created May 12, 2016 13:40
Using Array.reduce to sum a property in an array of objects
var accounts = [
{ name: 'James Brown', msgCount: 123 },
{ name: 'Stevie Wonder', msgCount: 22 },
{ name: 'Sly Stone', msgCount: 16 },
{ name: 'Otis Redding', msgCount: 300 } // Otis has the most messages
];
// get sum of msgCount prop across all objects in array
var msgTotal = accounts.reduce(function(prev, cur) {
return prev + cur.msgCount;
@alirobe
alirobe / reclaimWindows10.ps1
Last active April 26, 2024 17:59
This Windows 10 Setup Script turns off a bunch of unnecessary Windows 10 telemetery, bloatware, & privacy things. Not guaranteed to catch everything. Review and tweak before running. Reboot after running. Scripts for reversing are included and commented. Fork of https://github.com/Disassembler0/Win10-Initial-Setup-Script (different defaults). N.…
###
###
### UPDATE: For Win 11, I recommend using this tool in place of this script:
### https://christitus.com/windows-tool/
### https://github.com/ChrisTitusTech/winutil
### https://www.youtube.com/watch?v=6UQZ5oQg8XA
### iwr -useb https://christitus.com/win | iex
###
###
@davestevens
davestevens / LetsEncrypt.md
Last active March 28, 2024 10:35
Let’s Encrypt setup for Apache, NGINX & Node.js

Let's Encrypt

Examples of getting certificates from Let's Encrypt working on Apache, NGINX and Node.js servers.

Obtain certificates

I chose to use the manual method, you have to make a file available to verify you own the domain. Follow the commands from running

git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt
@fevangelou
fevangelou / my.cnf
Last active April 26, 2024 09:12
Optimized my.cnf configuration for MySQL/MariaDB (on Ubuntu, CentOS, Almalinux etc. servers)
# === Optimized my.cnf configuration for MySQL/MariaDB (on Ubuntu, CentOS, Almalinux etc. servers) ===
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# ~ Updated December 2021 ~
#
#
# The settings provided below are a starting point for a 8-16 GB RAM server with 4-8 CPU cores.
# If you have different resources available you should adjust accordingly to save CPU, RAM & disk I/O usage.
#
@gokulkrishh
gokulkrishh / media-query.css
Last active May 5, 2024 08:25
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
/* CSS */
@telekosmos
telekosmos / uniq.js
Last active November 15, 2022 17:13
Remove duplicates from js array (ES5/ES6)
var uniqueArray = function(arrArg) {
return arrArg.filter(function(elem, pos,arr) {
return arr.indexOf(elem) == pos;
});
};
var uniqEs6 = (arrArg) => {
return arrArg.filter((elem, pos, arr) => {
return arr.indexOf(elem) == pos;
});