Skip to content

Instantly share code, notes, and snippets.

View sirkitree's full-sized avatar

Jerad Bitner sirkitree

View GitHub Profile
@sirkitree
sirkitree / node.js
Last active December 24, 2018 15:31
Parse a PHP file with Node.js and convert an array defined in the PHP script into a JSON object which the Node app can use.
var runner = require('child_process');
runner.exec(
'php -r \'include("settings.php"); print json_encode($databases);\'',
function (err, stdout, stderr) {
var connection = JSON.parse(stdout).default.default;
console.log(connection.database);
// result botdb
}
@sirkitree
sirkitree / index.html
Created March 12, 2013 22:38
A CodePen by Jerad Bitner.
<html>
<body ng-app="nodes">
<div class="hero-unit" ng-controller="RecipeCtrl">
<button ng-click="useResource()">$resource request</button>
<ul>
<li ng-repeat="recipe in recipes.list">{{recipe.title}}</li>
</ul>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.min.js"></script>

PhpStorm for Drupal

PhpStorm has an excellent debugger for developing Drupal modules or even Drupal themes. After numerous IDE and text editors, it has earned it's place to be my primary IDE for almost anything Drupal, for many good reasons. PhpStorm, by default, is as Drupal friendly as many other PHP IDEs. That means it gets the job done, but there might be some syntax in your code the Drupal Coding Standards and it's authors wouldn't be too happy about. Here are a few things to make PhpStorm play well with Drupal.

Keymap

Althought not related to Drupal, the Keymap is the first thing we will change. PhpStorm by default comes with very unaturally keyboard shortcuts for me. Under Preferences, scroll down to select Keymap on the left. Select the keymap that suits your needs. Mac OS X 10.5+ feels the most intuitive to me. You may also further customize the keyboard shortcuts to each of the actions. ![Keymap](https://www.evernote.com/shard/s25/sh/6d5914ad-51f0-4d

@sirkitree
sirkitree / sct.info
Last active December 16, 2015 08:09
Image Style Scale and Crop from the top
; $Id$
name = Image Style Scale and Crop from the top
description = Image style to scale an image and crop it from the top.
core = 7.x
package = ImageStyles
@sirkitree
sirkitree / emoji.rb
Created July 10, 2013 14:14
Random Emoji command
ruby -e "print ':'+%w{zero one 109 two three four five six seven eight 8ball nine a ab airplane alien ambulance angel anger angry apple aquarius aries arrow_backward arrow_down arrow_forward arrow_left arrow_lower_left arrow_lower_right arrow_right arrow_up arrow_upper_left arrow_upper_right art astonished atm b baby baby_chick baby_symbol balloon bamboo bank barber baseball basketball bath bear beer beers beginner bell bento bike bikini bird birthday black_square blue_car blue_heart blush boar boat bomb book boot bouquet bow bowtie boy bread briefcase broken_heart bug bulb bullettrain_front bullettrain_side bus busstop cactus cake calling camel camera cancer capricorn car cat cd chart checkered_flag cherry_blossom chicken christmas_tree church cinema city_sunrise city_sunset clap clapper clock1 clock10 clock11 clock12 clock2 clock3 clock4 clock5 clock6 clock7 clock8 clock9 closed_umbrella cloud clubs cn cocktail coffee cold_sweat computer confounded congratulations construction construction_worker convenienc
@sirkitree
sirkitree / log_pos.js
Created October 31, 2014 00:48
log position in janus with a new text object
room.update = function(delta_time) {
global_update_val++;
global_time_passed += delta_time;
var secs_passed = global_time_passed * 0.001;
var sin_secs = Math.sin(secs_passed);
var sin_secs2 = Math.sin(secs_passed * 3.14159 * 2);
room.objects["new_text1"].text = "up/down = 1 & 7: " + (updown / 4);
room.objects["new_text1"].pos.y = 1.5 + 0.25*sin_secs;
@sirkitree
sirkitree / janus-rand.php
Last active August 29, 2015 14:09
Generate a random room from the vrsites subreddit for janusvr
<?php
/**
* Generate a random link from vrsites subreddit.
* Original author: http://www.reddit.com/user/MrM0bius
*/
$options = array('http' => array('user_agent' => 'JanusVR random site (v0.1)'));
$context = stream_context_create($options);
$rvrsites1 = file_get_contents('http://reddit.com/r/vrsites/.json?limit=100', false, $context);
<?php
$options = array('http' => array('user_agent' => 'JanusVR random site (v0.1)'));
$context = stream_context_create($options);
/**
* Should be able to use a more typical cache pattern here.
*
* Something like:
function _cache_get($var) {
static $cache_objects;
@sirkitree
sirkitree / index.html
Created November 19, 2014 05:11
Change websurface_id in Janus VR
<html>
<head>
<title>Lullabot loves you!</title>
</head>
<body>
This is an example of using the AssetWebSurface tag in Janus VR to insert a website as a texture on an object.
<FireBoxRoom>
<Assets>
<AssetObject id="plane" src="plane.obj" />
<AssetWebSurface id="lullabot" src="https://www.lullabot.com" width="1920" height="1080" />