This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dataURItoBlob(dataURI, callback) { | |
// convert base64 to raw binary data held in a string | |
// doesn't handle URLEncoded DataURIs - see SO answer #6850276 for code that does this | |
var byteString = atob(dataURI.split(',')[1]); | |
// separate out the mime component | |
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0] | |
// write the bytes of the string to an ArrayBuffer | |
var ab = new ArrayBuffer(byteString.length); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## React Setup with Vitejs | |
## To setup a react project is rather easy, simply pick the directory you want to store your projectn, | |
## open up a terminal there and run the following commands | |
npm init @vitejs/app vite-app --template react | |
or | |
npm init @vitejs/app vite-app --template vanilla |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
st := []byte("The quick brown fox jumps over the lazy dog") | |
l := len(st) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Amazon Elastic Beanstalk | |
## Grand the access to node command | |
1. sudo su | |
2. vipw | |
3. nodejs:x:496:494::/tmp:/bin/bash (":wq" to save changes) | |
4. sudo su nodejs | |
5: PATH=$PATH:`ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin | |
6: node -v (enjoy :) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hexToRgb(hex) { | |
// Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF") | |
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i; | |
hex = hex.replace(shorthandRegex, function(m, r, g, b) { | |
return r + r + g + g + b + b; | |
}); | |
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); | |
return result ? { | |
r: parseInt(result[1], 16), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"name": "b2c", | |
"color": "bfd4f2" | |
}, | |
{ | |
"name": "b2b", | |
"color": "bfd4f2" | |
}, | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"489":{"title":"chrome.bookmarks - Google Chrome","url":"https://developer.chrome.com/extensions/bookmarks#method-getTree"},"490":{"title":"Modern Web Apps With React and Redux - Reducers and Actions","url":"https://code.tutsplus.com/courses/modern-web-apps-with-react-and-redux/lessons/reducers-and-actions"},"491":{"title":"Life Less Literary - The Adventures of Dan Sumption","url":"http://www.sumption.org/"},"492":{"title":"Feature Toggles","url":"http://martinfowler.com/articles/feature-toggles.html"},"493":{"title":"The FACE of Amazon","url":"https://sites.google.com/site/thefaceofamazon/home"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function safeParse(n) { | |
n = +n; | |
if (isNaN(n)) throw new TypeError('NANUMERR'); | |
if (0 > n) throw new TypeError('NEGNUMERR'); | |
return n | |
} | |
function safeFixed(n) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// returns an array of src values for an currently selected element | |
copy([].slice.call($0.querySelectorAll('img')).map(function(el){ return el.getAttribute('src'); })) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var currentIndex = 0; | |
var listLength = 9; | |
var dir = 1; // -1 - to go backwards | |
var nextIndex = ((currentIndex + listLength) + dir) % listLength; |
NewerOlder