Skip to content

Instantly share code, notes, and snippets.

View shadowcodex's full-sized avatar
🐍
Pythoning

Shannon Duncan shadowcodex

🐍
Pythoning
View GitHub Profile
@shadowcodex
shadowcodex / firebase_firstime_user.js
Created December 7, 2015 23:38
Firebase: Detecting if user exists.This snippet detects if a user ID already exists, in order to do first time user functions.
// Assuming you have included the firebase script tag above this javascript
// For reference here is the tag: <script src="https://cdn.firebase.com/js/client/2.3.2/firebase.js"></script>
// Assumes you have already authenticated the user.
// Setup your firebase reference
var ref = new Firebase('https://your-app.firebaseIO-demo.com/');
// Setup a way to get your userid (Assuming using provided firebase authentication method...)
function getUser(authData) {
@shadowcodex
shadowcodex / teenager.js
Last active August 21, 2017 14:32
Programming a teanager
var body = require('human/body');
var emotions = require('human/emotions');
var teen = spawnHuman({age: 13});
const food = ['pizza', 'chicken nuggets', 'mac and cheese'];
var life = {
'feed': function(item) {
if(food.contains(item)){
life.consume(item);
} else {
@shadowcodex
shadowcodex / recurring.js
Last active August 21, 2017 14:30
Parse Recurring Dates
// Find n next dates from firstDate = "DD/MM/YYYY" always
// daysOfTheWeek = ["Monday", "Thursday"]
// k = every k weeks
function recurringTask(firstDate, k, daysOfTheWeek, n) {
var weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
var firstNDates = [];
var firstDay = firstDate.substring(0, 2);
@shadowcodex
shadowcodex / todo.md
Last active August 21, 2017 18:44
Projects To Do List

Project Ideas

  • "Just Another Editor"
    • Realtime collaborative editor
    • Angular 4 / Bootstrap 4 / Firebase
    • Mobile Tie In With Ionic
  • "Free Programming Ebooks"
    • Turn the free programming ebook repo into a usable and searchable site
    • Angular 4 / Bootstrap 4 / Firebase
  • Mobile Tie In With Ionic
@shadowcodex
shadowcodex / watching.md
Last active August 25, 2017 19:51
Watching Repo's

Repo's to keep an eye on

You can star a repo, which I do when I like something so I can find it easier later. So you end up with tons and tons of starred repo's...

You can watch a repo, but then you get notifications like crazy.

A different way

This is basically a list of repo's that I'm involved in some way shape or form, and use this gist to just get to them quickly from anywhere.

@shadowcodex
shadowcodex / project-include.html
Created August 28, 2017 18:45
Repeat section for every 4 items in data. Jekyll
{% assign rows = site.data.afcu-projects.size | divided_by: 4.0 | ceil %}
{% for i in (1..rows) %}
{% assign offset = forloop.index0 | times: 4 %}
<div class="row">
{% for proj in site.data.afcu-projects limit:4 offset:offset %}
<div class="col-md-3">
<div class="panel panel-default">
<div class="panel-heading">{{proj.title}}</div>
<div class="panel-body">
<p>{{proj.description}}</p>
@shadowcodex
shadowcodex / something.json
Created October 12, 2017 16:48
Angular 2+ and electron
"ngbuild": "ng build --base-href . --watch",
"cpbuild": "cp src/electron/* dist",
"build-electron": "npm-run-all --parallel ngbuild cpbuild electronrun",
"electronrun": "electron dist",
"start": "npm run build-electron",
@shadowcodex
shadowcodex / go-haloplatform.diff
Created August 20, 2018 21:51
Geth 1.8.2 -> Glo Diff FIle
This file has been truncated, but you can view the full file.
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
deleted file mode 100644
index a7b617655..000000000
--- a/.github/CODEOWNERS
+++ /dev/null
@@ -1,11 +0,0 @@
-# Lines starting with '#' are comments.
-# Each line is a file pattern followed by one or more owners.
-
-accounts/usbwallet @karalabe
@shadowcodex
shadowcodex / prisma.js
Last active August 23, 2018 00:34
Handle Prisma subscription using prisma-binding v2.1.3
const { Prisma } = require("prisma-binding");
const prisma = new Prisma({
typeDefs: "./../generated/prisma.graphql",
endpoint: "http://localhost:4466",
});
const handleIty = async (iterator, callback) => {
while (true) {
await iterator
@shadowcodex
shadowcodex / promise-all-resolve-all.js
Last active December 7, 2018 16:35
Prevent Promise.all fail fast
const resob = promise => {
return promise.then(result => ({ success: true, result })).catch(error => ({ success: false, error }))
}
const list = getListOfObjectsToHit();
let promises = list.map((value) => {
return resob(someAsyncProcess(value));
})