Skip to content

Instantly share code, notes, and snippets.

View gemmadlou's full-sized avatar

Gemma Black gemmadlou

View GitHub Profile
@gemmadlou
gemmadlou / example.ts
Created October 8, 2015 19:42
Chaining Promises And Recursive Functions
var loopData = [
// Array of Objects
]
EventRepo.GetEventById(req.body.event_id.toString())
.then(function (data: { rows: {}[] }) {
if (data.rows.length === 0)
throw new EventRepoError('Event with id:\'' + req.body.event_id + '\' does not exist');
@gemmadlou
gemmadlou / solution.js
Last active October 20, 2015 20:05
Maximum Call Stack Size Solution
// Must thank Mark McDonnell of Integralist
// http://www.integralist.co.uk/posts/js-recursion.html
// Below is his solution to prevent maximum call stack errors caused by calling
// functions recursively beyond the stack limit.
function tco(f) {
var value;
var active = false;
var accumulated = [];
@gemmadlou
gemmadlou / styles.css
Created January 15, 2016 08:25 — forked from pburtchaell/styles.css
VH and VW units can cause issues on iOS devices. To overcome this, create media queries that target the width, height, and orientation of iOS devices.
/**
* VH and VW units can cause issues on iOS devices: http://caniuse.com/#feat=viewport-units
*
* To overcome this, create media queries that target the width, height, and orientation of iOS devices.
* It isn't optimal, but there is really no other way to solve the problem. In this example, I am fixing
* the height of element `.foo` —which is a full width and height cover image.
*
* iOS Resolution Quick Reference: http://www.iosres.com/
*/
<?php
function free_and_premium() {
vc_map( array(
"name" => __("Premium", "js_composer"),
"base" => "premium",
"content_element" => true,
"category" => "content>",
"show_settings_on_create" => false,
"params" => array(
// add params same as with any other content element
@gemmadlou
gemmadlou / templates_vc_example.php
Created February 16, 2016 11:12
Visual Composer Shortcodes
<div class=" <?php echo esc_attr( $css_class ); ?> <?php echo $responsive_css; ?>">
<span class="headline <?php echo $settings_css; ?>">
<?php echo do_shortcode($content); ?>
</span>
</div>
<?php echo $this->endBlockComment('headings'); ?>
@gemmadlou
gemmadlou / example.html
Last active March 3, 2016 14:28
Responsive Full Container Width Script
<div data-hmd-full-width data-hmd-min-breakpoint="0" data-hmd-max-breakpoint="767"
style="position: relative; background-color: green;">
Example
</div>
@gemmadlou
gemmadlou / file-upload-button.html
Last active June 13, 2016 15:50
File Upload Button with Bootstrap
<label class="btn btn-default btn-file">
Browse <input type="file" style="display: none;">
</label>
@gemmadlou
gemmadlou / react-form-validation-getting-event-data.jsx
Last active June 15, 2016 14:59
React Form Validation & Getting Event Data Snippet
var React = require('react');
var ReactDOM = require('react-dom');
var Validation = require('../helpers/validation');
var has = require('../helpers/has');
var BasicInput = require('../components/basic-input');
var AppealForm = React.createClass({
validateInput: function(validatorFunc, e) {
// Notice position of event data
@gemmadlou
gemmadlou / getCache.js
Created June 18, 2016 09:04 — forked from contolini/getCache.js
Memoization of jQuery's $.getJSON() to use localStorage for caching.
var getCache = function(url) {
var supportsLocalStorage = 'localStorage' in window;
// Both functions return a promise, so no matter which function
// gets called inside getCache, you get the same API.
function getJSON(url) {
var promise = $.getJSON(url);
@gemmadlou
gemmadlou / aws-lambda.js
Last active June 22, 2016 12:31
AWS Login & Authentication
var AWS = require('aws-sdk');
var request = require('request');
var GOOGLE_CLIENT_ID = 'XXXXXX.apps.googleusercontent.com ';
var GOOGLE_URL = 'https: //www.googleapis.com/oauth2/v3/tokeninfo?id_token=';
var idPoolID = 'us-east-1:XXXXXXX';
var roleArn = 'arn:aws:iam::XXXXXX:role/Cognito_AdminStaffAuth_Role';
var cognitoidentity = new AWS.CognitoIdentity({
region: 'us-east-1'
});
module.exports = function(credentials, context) {