Skip to content

Instantly share code, notes, and snippets.

View deanshub's full-sized avatar

Dean Shub deanshub

View GitHub Profile
@deanshub
deanshub / gist:4613152
Last active December 11, 2015 14:18
javascript: browser detect
Detect Safari (if( $.browser.safari)),
Detect IE6 and over (if ($.browser.msie && $.browser.version > 6 )),
Detect IE6 and below (if ($.browser.msie && $.browser.version <= 6 )),
Detect FireFox 2 and above (if ($.browser.mozilla && $.browser.version >= '1.8' ))
@deanshub
deanshub / buildNodeWebkit
Created July 13, 2014 09:43
Automatically build node webkit app
#!/bin/sh
rm u2bear.nw
pushd ../u2bear
zip -r ../u2bearbuilder/u2bear * -x docs/* images/* videos/* songs/*
popd
mv u2bear.zip u2bear.nw
cat nw.exe u2bear.nw>u2bear.exe
rm ship/u2bear.exe
mv u2bear.exe ship/u2bear.exe
rm ship/songs/* ship/videos/* ship/images/* ship/u2bear.zip
@deanshub
deanshub / route.js
Created August 25, 2014 12:38 — forked from beshur/route.js
app.post('/login', function(req, res) {
console.log(res);
passport.authenticate('local', function(err, user, params) {
if (req.xhr) {
//thanks @jkevinburton
if (err) { return res.json({ error: err.message }); }
// e.g. in auth.js:
// if (!user.emailVerified) { return done(null, false, { message: 'Email is not verified. Please check your email for the link.' }); }
if (!user && params) { return res.json({error : params.error}); }
@deanshub
deanshub / sigma.plugins.nodesSelection.js
Created February 26, 2015 05:11
sigma.js plugin for multiple selection of nodes
(function() {
'use strict';
if (typeof sigma === 'undefined')
throw 'sigma is not declared';
sigma.utils.pkg('sigma.plugins');
var startPosition;
var WIDTH;
@deanshub
deanshub / palette.json
Created March 16, 2015 16:00
Google's material design color palette
{
"Red":{
"50":"#ffebee",
"100":"#ffcdd2",
"200":"#ef9a9a",
"300":"#e57373",
"400":"#ef5350",
"500":"#f44336",
"600":"#e53935",
"700":"#d32f2f",
@deanshub
deanshub / filer.js
Created June 26, 2016 15:51
passing through files doing whatever
var fs = require('fs');
var pathModule = require('path');
var Q = require('q');
var replace = require('replace');
function init(path, refactorFiles, destPath) {
// console.log(path);
findPattern(path, /language\.js$/).then(function (filesPaths) {
refactorFiles(filesPaths, destPath);
}).catch(console.log);
@deanshub
deanshub / rxExtention.js
Created March 14, 2017 10:22
rx operator for buffering by a window
import Rx from 'rxjs/Rx'
function emitByBuffer(subscriber, interval, buffer, lastUpdateTime){
// debugger
return new Promise(function (resolve) {
if (((Date.now() - lastUpdateTime) > interval) && buffer.length>0) {
subscriber.next(buffer)
return resolve(true)
} else if(buffer.length>0) {
setTimeout(()=>{
@deanshub
deanshub / ResponsiveText.js
Created February 21, 2018 12:04
responsive font size component
import React, { Component } from 'react'
export default class ResponsiveText extends Component {
static defaultProps = {
scale: 1,
}
constructor(props) {
super(props)
this.state = {
style: undefined,
}
@deanshub
deanshub / BodyClassName.js
Created March 26, 2018 16:15
Controlling css classes of body element with react
import React,{Component} from 'react'
import PropTypes from 'prop-types'
export default class BodyClassName extends Component {
static propTypes = {
className: PropTypes.string,
}
static defaultProps = {
className: '',
@deanshub
deanshub / AddVideoButton.js
Created October 9, 2018 05:28
how to add a button to draft inline toolbar
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import { AtomicBlockUtils, RichUtils } from 'draft-js'
import createVideoPlugin from 'draft-js-video-plugin'
const {types} = createVideoPlugin()
export default class AddVideoButton extends Component {
static propTypes = {
getEditorState: PropTypes.func,