Skip to content

Instantly share code, notes, and snippets.

View cacheflow's full-sized avatar
🎯
Focusing

Lex cacheflow

🎯
Focusing
View GitHub Profile
getPage(action, currentPage) {
let goToPage;
let userQuery = dom.getQueryFromPage()
this.fetchData(lookupPage(action)(currentPage), userQuery)
manipulateWindow.animateToTopOfPage()
}
lookupPage(goToPage) {
let pages = {
'prev': (page) {
function mergeDeep(destinationObj, sourceObj) {
for (var property in sourceObj) {
if (ensureIsObject(sourceObj[property], sourceObj[property].constructor)) {
destionationObj[property] = destionationObj[property] || {};
mergeDeep(destionationObj[property], sourceObj[property]);
}
else {
destionationObj[property] = sourceObj[property];
}
}
JS_PATH = "app/assets/javascripts/**/*.js";
Dir[JS_PATH].each do |file_name|
puts "\n#{file_name}"
puts Uglifier.compile(File.read(file_name))
end
(http|https):\/\/(www\.youtube\.com\/|youtu\.be\/)(watch\?v=.{11}|.{11})
function findSum(list, sum) {
let listCopy = list.slice(0).sort()
let start = 0
let end = list.length - 1
while(start <= end ) {
if(list[start] + list[end] == sum) {
return true
}
else if(list[start] + list[end] > sum) {
start += 1
'function counter() {
var today = new Date(); //variable contains current date and time
var days = calcDays(today); //calculate the time left until set date below
document.countDown.daysLeft.value = Math.floor(days); // displays days rounded to the next lowest integer
var hours = (days - Math.floor(days)) * 24; //calculate the hours left in the current day
document.countDown.hrLeft.value = Math.floor(hours); // display hours rounded to the next lowest integer
var minutes = (hours - Math.floor(hours)) * 60; // calculate the minutes left in the current hour
@cacheflow
cacheflow / flux.js
Last active January 20, 2017 02:48
class Dispatcher {
constructor() {
this._id = 0
this._cbs = {}
}
register(cb) {
this._cbs[this._id] = cb
return this._id++
}
unregister(id) {
/** jsx dom */
let dom = (tag, attrs, ...children) => {
return {tag, attrs, children}
}
const list = (
<ul class="list">
<li> Hope </li>
<li> This </li>
var fs = require('fs')
var path = require('path');
var imagePath = path.resolve(process.cwd(), 'assets/images')
console.log("starting script")
fs.readdir(imagePath, ((err, files) => {
files.filter(file => file.includes('@')).forEach((file) => {
var fileSplit = file.split('@')
var newImagePath = path.resolve(imagePath, fileSplit[0] + '.png')
var oldImagepath = path.resolve(imagePath, file)
fs.rename(oldImagepath, newImagePath, (err) => {
let converter = {
camelToSnake (data) {
return data.replace(/([A-Z])/g, (val) => "_" + val.toLowerCase())
},
snakeToCamel (data) {
return data.replace(/_([a-z])/g, function (g) { return g[1].toUpperCase(); });
}
}