Skip to content

Instantly share code, notes, and snippets.

@dreadjr
dreadjr / antd_sc_example.js
Created March 8, 2018 01:43 — forked from newswim/antd_sc_example.js
Wrapping Ant Design components with Styled Components
import { Link } from 'react-router-dom'
import { Badge, Col, Menu } from 'antd'
const StyledBadge = styled(Badge)`
.ant-badge-count {
background-color: #7ECBBF;
color: white;
box-shadow: 0 0 0 1px #d9d9d9 inset;
}
`
@dreadjr
dreadjr / rxjs-firebase-demo.js
Created November 28, 2017 19:59 — forked from deltaepsilon/rxjs-firebase-demo.js
Demo RxJs integration with Firebase
var Rx = require('rxjs');
var firebase = require('firebase');
firebase.initializeApp({
"databaseURL": "https://quiver-two.firebaseio.com",
"serviceAccount": "./service-account.json"
});
var ref = firebase.database().ref('rxjs-demo');
Rx.Observable.fromPromise(ref.remove())
.map(function () {
@dreadjr
dreadjr / promises_reduce.js
Created November 15, 2017 16:30 — forked from anvk/promises_reduce.js
Sequential execution of Promises using reduce()
function asyncFunc(e) {
return new Promise((resolve, reject) => {
setTimeout(() => resolve(e), e * 1000);
});
}
const arr = [1, 2, 3];
let final = [];
function workMyCollection(arr) {
@dreadjr
dreadjr / makeTemplate.js
Created September 22, 2017 19:01 — forked from malko/makeTemplate.js
dynamic es6 template string to template methods
//const tpl = makeTemplate('hello ${name}')
//const name = 'world';
//tpl({name});
const makeTemplate = (templateString) => {
return (templateData) => new Function(`{${Object.keys(templateData).join(',')}}`, 'return `' + templateString + '`')(templateData);
}
@dreadjr
dreadjr / pbcopy.js
Created July 20, 2017 16:46 — forked from mkremins/pbcopy.js
node.js: put text into OS X clipboard
function pbcopy(data) {
var proc = require('child_process').spawn('pbcopy');
proc.stdin.write(data);
proc.stdin.end();
}
var saveUser = function(user, cb) {
var ref = new Firebase("https://<your-firebase>.firebaseio.com");
var usersRef = ref.child('users');
usersRef.child('count').once('value', function(snap) {
var priority = snap.val() ? snap.val() : 0;
usersRef.child(user.uid).setWithPriority(user, priority, function() {
// on complete, update user count
usersRef.child('count').transaction(function (current_value) { return (current_value || 0) + 1; });
});
@dreadjr
dreadjr / UserCreateFirebase.js
Created July 5, 2017 22:06 — forked from codenamejason/UserCreateFirebase.js
Create user if does not exist already
function go() {
var userId = prompt('Username?', 'Guest');
var userData = { name: userId };
tryCreateUser(userId, userData);
}
var USERS_LOCATION = 'https://<Firebase URL>.com/users';
function userCreated(userId, success) {
if (!success) {
@dreadjr
dreadjr / Appfile.rb
Created May 31, 2017 22:41 — forked from ravishtiwari/Appfile.rb
Ionic Build IPA with Fastlane tool
app_identifier "com.yourorganization.mytodoapp" # The bundle identifier of your app
apple_id "<You Apple Id>" # Your Apple email address
# You can uncomment any of the lines below and add your own
# team selection in case you're in multiple teams
# team_name "CAMobileApp"
# team_id "Q2CBPJ58CA"
# you can even provide different app identifiers, Apple IDs and team names per lane:
# https://github.com/KrauseFx/fastlane/blob/master/docs/Appfile.md
@dreadjr
dreadjr / timestamp_version_bump.js
Created April 28, 2017 20:03
Apache Cordova build hook to auto bump iOS CFBundleVersion and Android versionCode
#!/usr/bin/env node
var fs = require("fs"),
path = require("path");
var rootdir = process.argv[2];
if (rootdir) {
module.exports = function(context) {
@dreadjr
dreadjr / Stop Permssion Errors on Firebase & AngularFire Logout - README.md Prevent permission denied errors from Firebase on logout (caused by active $firebaseArray & $firebaseObject connections not being destroyed). Example code follows John Papa's style guide.