Skip to content

Instantly share code, notes, and snippets.

View James1x0's full-sized avatar
Building

James James1x0

Building
View GitHub Profile
@James1x0
James1x0 / wp-ffmpeg-thumbnail
Created January 7, 2014 20:03
Wordpress Thumbnail Generation with ffmpeg-php.
function ExtractThumb($in, $out) {
$thumb_stdout;
$errors;
$retval = 0;
// Delete the file if it already exists
if (file_exists($out)) { unlink($out); }
// Use ffmpeg to generate a thumbnail from the movie
$cmd = "ffmpeg -i $in -ss 00:00:01 -f image2 -vframes 1 -s 300x200 $out";
exec($cmd, $thumb_stdout, $retval);
// Queue up the error for processing
@James1x0
James1x0 / momentjs.humanized.triplesplit.time.js
Created January 15, 2014 19:42
Get a humanized, "Morning", "Afternoon", "Evening" from moment.js **Great for user greetings!**
function getGreetingTime (m) {
var g = null; //return g
if(!m || !m.isValid()) { return; } //if we can't find a valid or filled moment, we return.
var split_afternoon = 12 //24hr time to split the afternoon
var split_evening = 17 //24hr time to split the evening
var currentHour = parseFloat(m.format("HH"));
if(currentHour >= split_afternoon && currentHour <= split_evening) {
@James1x0
James1x0 / pyback.py
Created April 23, 2014 21:55
Python Mongodb Backup to use sftp and sendmail to alert
#!/usr/bin/python
# import modules used here
import zipfile
import os
import shutil
import sys
import subprocess
import datetime
import pysftp as sftp
import DS from "ember-data";
var attribute = DS.attr;
export default DS.Model.extend({
name: attribute({
first: attribute('string'),
last: attribute('string')
}),
time_stamp: attribute('string', {
@James1x0
James1x0 / emberscrollspy.js
Last active January 30, 2017 17:28
Ember Scrollspy
import Ember from 'ember';
import windowBinderMixin from '../mixins/window-binder';
export default Ember.View.extend(windowBinderMixin, {
templateName: 'scroll-spy',
classNames: [ 'scroll-spy-view', 'affix' ],
// Bind the window events on view insertion
didInsertElement: function () {
this.setupWindowBindings();
@James1x0
James1x0 / windowbindermixin.js
Created July 17, 2014 16:43
Window Event Binder Mixin
import Ember from 'ember';
// This mixin binds callbacks to events.
export default Ember.Mixin.create({
/*
Mixin setup
NOTE: Must be implemented on init, didTransition, or didInsertElement hooks
*/
setupWindowBindings: function () {
@James1x0
James1x0 / session.js
Created July 24, 2014 17:03
Session Initializer
export default {
name: 'session',
after: 'store',
initialize: function (container, app) {
app.deferReadiness();
var store = container.lookup('store:main');
store.find('session', { active: true }).then(function (ses) {
container.lookup('controller:session').set('content', ses);
container.typeInjection('controller', 'session', 'controller:session');
@James1x0
James1x0 / session.js
Created July 24, 2014 17:05
Session Controller
import Ember from 'ember';
/*
App Initialized Session Controller
*/
export default Ember.Controller.extend({
logout: function () {
// Find the session
var ses = this.store.find('session', this.get('content').get('id'));
@James1x0
James1x0 / json-to-html.js
Created August 20, 2014 20:01
JSON To HTML table
/*
Quick and dirty JSON to HTML table parser
---
Designed for use debugging in node.js
*/
function jsonToHtml ( json, limit ) {
var data = json,
dataKeys = [];
@James1x0
James1x0 / w.js
Created August 28, 2014 16:04
Window prop
export default Ember.View.extend({
didInsertElement: function () {
this.$().on('scroll', { emEl: this }, this._updatePosition);
},
_updatePosition: function ( ev ) {
Ember.run.throttle(ev.data.emEl, function () {
this.set('scrollY', ev.currentTarget.scrollY);
}, 250);
}