Skip to content

Instantly share code, notes, and snippets.

@etyp
etyp / load
Last active August 29, 2015 14:23
Image loads
var $bgImages = $('.background-image');
var loadCount = 0;
$bgImages.each(function (index) {
// Get source based on size
var src = isMobile() ? $(this).attr('data-mobile') : $(this).attr('data-desktop') ;
// Set source
this.src = src;
// example HTML:
// <img class="background-image" src="images/mobile/everydaycare.jpg">
// Description: Serve mobile image first, and swap directory if page is desktop
function swapImageMobileFirst() {
var $bgImages = $('img.background-image');
var loadCount = 0;
$bgImages.each(function(){
// Get image src
@etyp
etyp / hello.js
Created September 1, 2015 21:13
An example of checking is meteor is running with electron or not
Meteor.isElectron = false;
if (Meteor.isClient) {
Meteor.isElectron = (typeof window.require !== 'undefined');
}
if (Meteor.isElectron) {
console.log("Running on desktop");
var ipc = window.require('ipc');
Template.hello.events({
@etyp
etyp / gulpfile.js
Last active September 2, 2015 01:27
var gulp = require('gulp');
var watch = require('gulp-watch');
var shell = require('gulp-shell');
// reload task
gulp.task('reload', shell.task([
'echo hello' // do your shell commands here - works as an array of commands if you want to add more
]));
// watch files
@etyp
etyp / colors.js
Created September 24, 2015 21:45
color randoms
var colors = [];
for (var i = 0, temp; i < 40; i++) {
colors.push("hsl(" + (i * 360 / 40) + ", 100%, 50%)");
}
var remote = nodeRequire('remote');
var fs = remote.require('fs');
// Get date time
var now = new Date();
// Create file name based on date
var fileName = now.getFullYear() + '-' + now.getMonth() + '-' + now.getDay() + '-at-' + now.getHours() + '-' + now.getMinutes() + '-' + now.getSeconds() + '-tasting.json';
// Write data into the json folder
fs.writeFile('HARDCODE-TASTING-DATE-DIR-HERE' + '/' + fileName, data, function (err) {
if (Meteor.isClient) {
Meteor.startup(function () {
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera( 75, window.innerWidth/window.innerHeight, 0.1, 1000 );
renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
geometry = new THREE.BoxGeometry( 1, 1, 1 );
mainWindow = new BrowserWindow({
width: size.width < 1600 ? size.width - 50: size.width - 100,
height: size.width < 1600 ? size.height - 50: size.height - 100,
title: 'Hive: Home for busy teams',
/**
* Disable Electron's Node integration so that browser dependencies like `moment` will load themselves
* like normal i.e. into the window rather than into modules, and also to prevent untrusted client
* code from having access to the process and file system:
* - https://github.com/atom/electron/issues/254
* - https://github.com/atom/electron/issues/1753
@etyp
etyp / chmln.js
Created August 9, 2016 15:29
loaded chmln
(function(win,doc,root) {
var elusiveToUsers = /user/.test(root.elusive),
elusiveToAdmins = /admin/.test(root.elusive),
dataLoaded,
urlOptions = { host: win.location.hostname};
root.location || (root.location = win.location.href.toString());
if(root.root || elusiveToUsers) {
return;
const dns = require('dns');
setInterval(() => {
dns.resolve('hive.com', (error) => {
if (error) console.log(error);
else console.log('Connected!');
});
}, 1000);