Skip to content

Instantly share code, notes, and snippets.

View Yogatopia's full-sized avatar
👨‍💻
Coding

Armand Lacle Yogatopia

👨‍💻
Coding
View GitHub Profile
@Yogatopia
Yogatopia / index.js
Created April 20, 2017 11:38
Cloud Function for Push Notification
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
/**
* Triggers when new subject added in the list and sends a notification.
*/
exports.sendNotification = functions.database.ref('/subjects/{subjectKey}').onWrite((event) => {
import { Directive } from '@angular/core';
import { ViewController } from 'ionic-angular';
@Directive({
selector: '[hideTabs]'
})
export class HideTabsDirective {
constructor(private viewCtrl: ViewController) {
// hide tabs when view loads
@Yogatopia
Yogatopia / 0firebase_functions_cheatsheet.js
Created April 20, 2017 08:23
firebase_functions_cheatsheet.js
// Core
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
const db = admin.database();
admin.auth().createUser({
uid: uid,
displayName: displayName,
photoURL: photoURL
@Yogatopia
Yogatopia / app.js
Created April 20, 2017 11:42
AppServer code for Push Notification
var firebase = require('firebase-admin');
var request = require('request');
// Fetch the service account key JSON file contents
var serviceAccount = require("path/to/serviceAccountKey.json");
var env = require("path/to/env.json");
// Your Firebase Cloud Messaging Server API key
var API_KEY = env.CLOUD_MESSAGE_API_KEY;
@Yogatopia
Yogatopia / Index.html
Last active October 5, 2015 15:07
Instafeed.js
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
<title>Instagram.js</title>
<link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="node_modules/instafeed.js/instafeed.min.js"></script>
<style>
@Yogatopia
Yogatopia / wp-snippets.php
Created January 26, 2012 16:18 — forked from matiskay/wp-snippets.php
Wordpress Snippets Functions
<?php
// http://johnford.is/programmatically-pull-attachments-from-wordpress-posts/
// http://www.wprecipes.com/how-to-show-wordpress-post-attachments
// get all of the images attached to the current post
function _get_images($size = 'thumbnail') {
global $post;
$photos = get_children( array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') );
@Yogatopia
Yogatopia / Intervals.py
Created July 4, 2015 13:17
Python Snippets
import threading
def do_every (interval, worker_func, iterations = 0):
if iterations != 1:
threading.Timer (
interval,
do_every, [interval, worker_func, 0 if iterations == 0 else iterations-1]
).start ()
worker_func ()
@Yogatopia
Yogatopia / onbeforeunload-1.js
Created June 1, 2015 09:43
Confirmation on Leaving the Current Page in JavaScript
function goodbye(e) {
if(!e) e = window.event;
//e.cancelBubble is supported by IE - this will kill the bubbling process.
e.cancelBubble = true;
e.returnValue = 'You sure you want to leave?'; //This is displayed on the dialog
//e.stopPropagation works in Firefox.
if (e.stopPropagation) {
e.stopPropagation();
e.preventDefault();
@Yogatopia
Yogatopia / 2_keyboard_shortcuts.md
Last active August 29, 2015 14:20
Here are some things you can do with Gists in GistBox.

Create documentation for your projects. Like so:


Most popular keyboard shortcuts within GistBox

  • Up/Down - Previous/Next Gist
  • Ctrl+e - Edit a selected Gist
  • Ctrl+s - Save Gist