Skip to content

Instantly share code, notes, and snippets.

View bmadigan's full-sized avatar

Brad Madigan bmadigan

View GitHub Profile
var adp = Titanium.API.Application.getDataPath();
var dbpath = adp+"\\"+"sampledb.db";
var db = Titanium.Database.openFile(dbpath);
db.execute('CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, firstname VARCHAR(50), lastname VARCHAR(50))');
var firstname = $("input#firstname").val();
var lastname = $("input#lastname").val();
db.execute("INSERT INTO users (firstname, lastname) VALUES (?, ?)", firstname, lastname);
try {
var adp = Titanium.API.Application.getDataPath();
var dbpath = adp+"\\"+"sampledb.db";
var db = Titanium.Database.openFile(dbpath);
//var db = Titanium.Database.open('recruitment'); // this doesn't work either
}
catch (e) {
alert(e); // seems to connect as this doesn't come up
}
@bmadigan
bmadigan / bundler.error.rb
Created March 29, 2012 22:23
Heroku Bundler Error
# Heroku: bamboo-mri-1.9.2 -- I was trying Cedar to no avail as well.
# Heroku Bundler Version 1.0.7
# Local Version is: ( Bundler version 1.1.0 ) not sure if this matters
# Error I am receiving:
# You have modified your Gemfile in development but did not check
# the resulting snapshot (Gemfile.lock) into version control
#
# You have added to the Gemfile:
# * libnotify
@bmadigan
bmadigan / parse_csv.php
Created April 17, 2012 15:23
Parse A CVS File
$csv_file = 'export-test.csv';
ini_set("auto_detect_line_endings", true); // Needed for for some reason
$csvfile = fopen($csv_file,'rb');
echo '<h3>Importing CSV File into system ...</h3>';
while(!feof($csvfile)) {
$csvarray[] = fgetcsv($csvfile);
}
@bmadigan
bmadigan / Chrome-Logger-Instructions
Created April 11, 2013 15:47
Instructions for setting up Chrome Logger Extension
Install the logger: http://craig.is/writing/chrome-logger
Put ChromePhp.php somewhere in your PHP include path
include 'ChromePhp.php';
ChromePhp::log('Hello console!');
ChromePhp::log($_SERVER);
ChromePhp::warn('something went wrong!');
Ruby: https://github.com/cookrn/chrome_logger
@mixin box-shadow($top, $left, $blur, $color, $inset: false) {
@if $inset {
-webkit-box-shadow:inset $top $left $blur $color;
-moz-box-shadow:inset $top $left $blur $color;
box-shadow:inset $top $left $blur $color;
} @else {
-webkit-box-shadow: $top $left $blur $color;
-moz-box-shadow: $top $left $blur $color;
box-shadow: $top $left $blur $color;
}
@bmadigan
bmadigan / sample-shopify-variant-remove.rb
Last active December 20, 2015 12:49
Sample Variant call
def destroy_shopify_variant(variant_id)
ShopifyAPI::Variant.delete({ :id => variant_id })
end
@bmadigan
bmadigan / Company-People-JSON
Last active August 29, 2015 13:56
Sample Laravel JSON Output
{
companies: [
{
id: 1,
name: "Apple",
created_at: "0000-00-00 00:00:00",
updated_at: "0000-00-00 00:00:00",
people: [
{
id: 2,
@bmadigan
bmadigan / sample-cdn-jquery.html
Created February 20, 2014 16:47
JQuery from CDN or Local copy if not define
// First try loading jQuery from Google's CDN
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
// Fall back to a local copy of jQuery if the CDN fails
<script>
window.jQuery || document.write('<script src="http://mysite.com/jquery.min.js"><\/script>'))
</script>
@bmadigan
bmadigan / MysqlDump.php
Last active August 29, 2015 13:57
Create A Mysqldump of the current snapshot of a mysql database for Codeception.
<?php
// Add to app/start/artisan.php
// Artisan::add(new MysqlDump);
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
class MysqlDump extends Command {