Skip to content

Instantly share code, notes, and snippets.

View boostup's full-sized avatar
💭
👍

Fred B. boostup

💭
👍
View GitHub Profile
// jsconfig.json
{
"compilerOptions": {
"baseUrl": "./src"
},
"include": ["src"]
}
// .eslintrc
{
@boostup
boostup / reset.css
Created September 8, 2020 18:11 — forked from DavidWells/reset.css
CSS reset. Follow me on the twitters for more tips: https://twitter.com/davidwells
/* http://meyerweb.com/eric/tools/css/reset/
v2.0-modified | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
@boostup
boostup / openVSCodeHotKeyUbuntu.py
Last active August 18, 2020 09:23
This script is to open a particular directory directly in VSCode using a custom hot key in Ubuntu.
#!/usr/bin/env python3
import subprocess
import pyperclip
import os
import sys
subprocess.call(["xdotool", "key", "Control_L+c"])
prefix, absPath = pyperclip.paste().split('file://')
#Dealing with paths containing whitespaces which are replaced with "%20" in the clipboard string value of absPath variable
dirPath = absPath.strip().replace("%20", " ")
function createRecord(count) {
let records = [];
for (let i = 0; i < count; i++) {
records[i] = {
text: `username_${i}`,
};
}
return records;
}
const responseGoogleStatus = (responseType) => {
return (response) => {
console.log(responseType, response);
if (responseType == "Success") {
loggedIn = true;
token = response.accessToken;
}
if (responseType == "Failed") {
throw new Exception("Some error from Google API response", response);
const formatForHtml = (textString) => {
return textString.split("\n").map(function (line, idx) {
return (
<div key={idx}>
{`${line}`}
<br />
</div>
);
});
};
@boostup
boostup / stamp-it.js
Last active June 5, 2018 23:05
This code is some quick and dirty one! This is not meant for production code. It is meant to run as bookmarklet on chrome latest. On the browser, the page opened must be a playing video at https://www.youtube.com. Then, clicking on the bookmarklet containing this code will allow to log into the browser console the video metadata, time elapsed al…
function minTohhmmss(totalSeconds){
var hours = Math.floor(totalSeconds / 3600);
totalSeconds %= 3600;
var minutes = Math.floor(totalSeconds / 60);
var seconds = Math.floor(totalSeconds % 60);
var ret = "";
hours ? ret = hours + "h" : "";
minutes ? ret += minutes + "m": "";
@boostup
boostup / readJsonFileAsync.js
Created March 30, 2018 08:13 — forked from wuchengwei/readJsonFileAsync.js
NodeJS - Read in a json file asynchronously
/*
* @param {String} filepath
* @param {function} callback function(err, data){}
*/
function readJsonFileAsync(filepath, callback) {
var fs = require('fs');
fs.readFile(filepath, 'utf-8', function(err, data) {
if (err) { callback(err, null); }
else {
result = JSON.parse(data);
@boostup
boostup / createFile.js
Last active December 13, 2017 14:03
create huge file. then create readable stream with file and flush out line by line to the console
const fs = require('fs');
const file = fs.createWriteStream('./big.file');
for(let i=0; i<= 500000; i++) {
file.write('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n');
}
file.end();
@boostup
boostup / server.js
Last active July 24, 2020 10:43 — forked from RichFromGalvanize/gist:5873044
node.js: an image piping example using express and request
var request = require('request');
var express = require('express');
var app = express();
app.get('/goofy', function(req, res) {
request('http://images1.wikia.nocookie.net/__cb20120715102950/disney/images/a/a5/Disneygoofy2012.jpeg').pipe(res);
});
app.get('/loop', function(req, res) {
res.render('mypage');