Skip to content

Instantly share code, notes, and snippets.

View danBamikiya's full-sized avatar
:octocat:
call me a sci-tech engineer

Dan Bamikiya danBamikiya

:octocat:
call me a sci-tech engineer
View GitHub Profile
@jaysonrowe
jaysonrowe / FizzBuzz.js
Created January 11, 2012 01:39
FizzBuzz JavaScript solution
for (var i=1; i <= 20; i++)
{
if (i % 15 == 0)
console.log("FizzBuzz");
else if (i % 3 == 0)
console.log("Fizz");
else if (i % 5 == 0)
console.log("Buzz");
else
console.log(i);
@mbostock
mbostock / .block
Last active March 1, 2024 12:32 — forked from mbostock/.block
Tidy Tree
license: gpl-3.0
border: no
height: 2000
redirect: https://beta.observablehq.com/@mbostock/d3-tidy-tree
@millermedeiros
millermedeiros / example.js
Last active September 10, 2022 03:06
execute multiple shell commands in series on node.js
// USAGE ------
// ============
var shell = require('./shellHelper');
// execute a single shell command
shell.exec('npm test --coverage', function(err){
console.log('executed test');
}});
@etaubman
etaubman / ShortenNumbers.js
Last active April 10, 2021 23:11
Shorten Numbers Using Javascript
function shortenNumber(n, d) {
if (n < 1) return "<1";
var k = n = Math.floor(n);
if (n < 1000) return (n.toString().split("."))[0];
if (d !== 0) d = d || 1;
function shorten(a, b, c) {
var d = a.toString().split(".");
if (!d[1] || b === 0) {
return d[0] + c
@andrew8088
andrew8088 / stringify.js
Last active August 23, 2022 07:54
A simple implementation of JSON.stringify; covers every case I could think of
function stringify(obj) {
if (typeof obj !== 'object' || obj === null || obj instanceof Array) {
return value(obj);
}
return '{' + Object.keys(obj).map(function (k) {
return (typeof obj[k] === 'function') ? null : '"' + k + '":' + value(obj[k]);
}).filter(function (i) { return i; }) + '}';
}
@ChaseFlorell
ChaseFlorell / Execute.ps1
Last active July 28, 2021 11:03
Passing switches to child functions within PowerShell
# this is the final (child) function being called
function Invoke-Foo {
[cmdletbinding()]
param([switch] $Custom)
Write-Host 'Hello world'
Write-Verbose 'I''m a verbose message'
Write-Debug 'I''m a debug message' #this will pause execution
if($Custom.IsPresent){
Write-Host 'I''m a custom message'
@paulirish
paulirish / webfont-performance-notes.md
Last active April 2, 2024 17:36
webfont performance notes

Just jotting some notes on delivering webfonts performantly…

still an incomplete draft.

Any critical fonts must be requested asap.

Critical fonts are neccessary for the above-the-fold content to be useful. Identify which of the fonts you NEED for the first render, as they get very different treatment vs the others.

You want the network reqs for your critical fonts to start ASAP. ideally the @font-face req is in a style tag, following CRP guidelines

@blueskyarea
blueskyarea / git command
Last active April 19, 2021 16:15
git-command
// add remote repository to local git
git remote add origin {remote repository url}
// pushes up the all repository
git push -u origin --all
// pushes up any tags
git push -u origin --tags
// cancel one before commit
@paulirish
paulirish / what-forces-layout.md
Last active May 23, 2024 14:12
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@samccone
samccone / README.md
Last active October 26, 2023 05:17 — forked from mbostock/.block
Reingold–Tilford Tree

The tree layout implements the Reingold-Tilford algorithm for efficient, tidy arrangement of layered nodes. The depth of nodes is computed by distance from the root, leading to a ragged appearance. Radial orientations are also supported. Implementation based on work by Jeff Heer and Jason Davies using Buchheim et al.'s linear-time variant of the Reingold-Tilford algorithm. Data shows the Flare class hierarchy, also courtesy Jeff Heer.

Compare to this radial layout.