Skip to content

Instantly share code, notes, and snippets.

View Kokil's full-sized avatar
🙃

Kokil Kokil

🙃
View GitHub Profile

###Prerequesites

Install flightplan globally

npm install -g flightplan

Install flightplan in your project folder

<?php
if ($modx->event->name !== 'OnWebLogin')
return;
$usergroups = $user->getUserGroupNames();
if(empty($usergroups))
return;
switch (TRUE) {
@Kokil
Kokil / gist:efaf9cfd06b3f41a134c
Last active August 29, 2015 14:26 — forked from boucher/gist:1750375
Stripe PHP simple example
<?php
require 'path-to-Stripe.php';
if ($_POST) {
Stripe::setApiKey("YOUR-API-KEY");
$error = '';
$success = '';
try {
if (!isset($_POST['stripeToken']))
throw new Exception("The Stripe Token was not generated correctly");
@Kokil
Kokil / gist:8358ea5a3db6caad424f
Last active September 1, 2015 05:41
Simple send an email via Mandrill API. I could not find this anywhere else so hopefully it is helpful to somebody else. At this point you should be able to look at the api docs and figure out the different options.
// Send Email
require_once 'Mandrill.php';
$mandrill = new Mandrill($apikey);
$message = new stdClass();
$message->html = "html message";
$message->text = "text body";
$message->subject = "email subject";
$message->from_email = "address@test.com";
@Kokil
Kokil / .gitignore
Created November 27, 2015 14:53 — forked from octocat/.gitignore
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@Kokil
Kokil / canvas-upload.php
Created December 27, 2015 09:17 — forked from fazlurr/canvas-upload.php
Function to save base64 image to png with PHP
<?php
// requires php5
define('UPLOAD_DIR', 'images/');
$img = $_POST['img'];
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
$file = UPLOAD_DIR . uniqid() . '.png';
$success = file_put_contents($file, $data);
print $success ? $file : 'Unable to save the file.';
@Kokil
Kokil / SparkCoreEventRecorder.js
Created January 3, 2016 10:38 — forked from harrisonhjones/SparkCoreEventRecorder.js
NodeJS SparkCore Event Recorder
// Includes
var EventSource = require('eventsource');
var mysql = require('mysql');
// Variables
var deviceID = "***FILL THIS IN***";
var accessToken = "***FILL THIS IN***";
// Mysql Connection
var connection = mysql.createConnection({
@Kokil
Kokil / install.sh
Created January 21, 2016 10:54 — forked from fideloper/install.sh
Vagrant Provisioning Script for PHP applications. This installs a LAMP stack.
#!/usr/bin/env bash
echo ">>> Starting Install Script"
# Update
sudo apt-get update
# Install MySQL without prompt
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
@Kokil
Kokil / capistrano-laravel-deploy.rb
Created January 25, 2016 05:10 — forked from arhea/capistrano-laravel-deploy.rb
Capistrano 3 deploy script for Laravel 4.
# config valid only for Capistrano 3.1
lock '3.1.0'
set :application, "" # EDIT your app name
set :scm, :git
set :repo_url, "" # EDIT your git repository
set :keep_releases, 3