Skip to content

Instantly share code, notes, and snippets.

View CGastrell's full-sized avatar

Christian Gastrell CGastrell

View GitHub Profile
@CGastrell
CGastrell / git_branch.sh
Created August 20, 2018 16:12 — forked from dciccale/git_branch.sh
Bash script to get the current git branch and last commit
#!/usr/bin/env bash
# checks if branch has something pending
function parse_git_dirty() {
git diff --quiet --ignore-submodules HEAD 2>/dev/null; [ $? -eq 1 ] && echo "*"
}
# gets the current git branch
function parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
@CGastrell
CGastrell / modal-nightmare.js
Created February 1, 2017 05:40
descriptive user decision path with a modal and unsaved data confirmation nested confirm modal
click: function (event) {
event.stopPropagation()
this.form = new EditFormView({ model: this.model, availableCustomers: this.availableCustomers })
// the created form eliminates the class, dunno why
this.form.el.classList.add('form-horizontal')
const originalData = merge({}, this.form.data)
const modal = bootbox.form(
{
#!/bin/env bash
echo "ok"
@CGastrell
CGastrell / DrawBuffer.js
Last active October 6, 2015 17:02
Buffer control
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
* full list of contributors). Published under the 2-clause BSD license.
* See license.txt in the OpenLayers distribution or repository for the
* full text of the license. */
/**
* @requires OpenLayers/Control.js
* @requires OpenLayers/StyleMap.js
* @requires OpenLayers/Feature/Vector.js
@CGastrell
CGastrell / test.html
Created July 21, 2015 20:48
Sample mail structure
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>
<body bgcolor="#0093D0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
@CGastrell
CGastrell / camera.html
Last active August 29, 2015 14:21 — forked from dhavaln/camera.html
<!DOCTYPE html>
<html>
<head>
<title>Capture Photo</title>
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1"/>
<script type="text/javascript" charset="utf-8" src="js/phonegap.js"></script>
<script type="text/javascript" charset="utf-8">
var pictureSource; // picture source
var destinationType; // sets the format of returned value
@CGastrell
CGastrell / sample2.css
Last active August 29, 2015 14:15
Example of or in media queries
body {
font-size: 14px;
}
/* targeting iPhones 1 through 5 and any other device which height is less than 480px */
@media screen and (max-device-width: 320px, max-device-height: 480px) {
body: {
font-size: 16px;
}
}
@CGastrell
CGastrell / sample.css
Last active August 29, 2015 14:15
Building media queries
body {
font-size: 14px;
}
/*
...
bunch of lines with excellent css
...
*/
/* targeting iPhones from 1 through 5 */
@CGastrell
CGastrell / snow
Created December 20, 2014 18:19
found at popcorntime.io
var popcorn={initialize:function(){this.polyfill(),analytics.initialize({"Google Analytics":{trackingId:"UA-38440155-3",domain:"popcorntime.io",universalClient:!0}}),analytics.pageview()},polyfill:function(){for(var a=["ms","moz","webkit","o"],b=0;b<a.length&&!window.requestAnimationFrame;b++)window.requestAnimationFrame=window[a[b]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[a[b]+"CancelAnimationFrame"]||window[a[b]+"CancelRequestAnimationFrame"]},detectUA:function(a){return/Mac/.test(a)?"mac":/Win/.test(a)?"win":/Lin/.test(a)?/x86_64/.test(a)?"lin-64":"lin-32":void 0},updateDownloads:function(a){document.body.className+=" "+(this.detectUA(a)||"nope")},updateStatus:function(a,b){$.get(b,function(b){$(a).addClass(b.status.indicator)},"json")},smoothScroll:function(){$("a[data-scroll][href*=#]:not([href=#])").click(function(){if(location.pathname.replace(/^\//,"")==this.pathname.replace(/^\//,"")&&location.hostname==this.hostname){var a=$(this.hash);if(a=a.length?a:$("[name="+this.hash.slice(1)
@CGastrell
CGastrell / README.md
Last active August 29, 2015 14:08 — forked from shedd/README.md

Usage

Install cordova into node_modules

npm install cordova

Add icons_and_splash.js