Skip to content

Instantly share code, notes, and snippets.

@clouddueling
clouddueling / modulePattern.js
Created September 9, 2013 21:16
module pattern
var NewsWidget = (function(window, document, undefined){
// private
var name = ‘Chris’;
function createMember() {
}
// public
return {
@clouddueling
clouddueling / jbclock.js
Created September 8, 2013 19:03
jbclock angularjs directive
directives.directive('jbclock', function(){
return {
scope: {
startDate: '=',
endDate: '=',
},
link: function(scope, elm, attrs, controller) {
JBCountDown({
secondsColor: attrs.secondsColor || "#ffdc50",
@clouddueling
clouddueling / infiniteScroll.js
Last active December 22, 2015 09:38
infinite scroll for fixed positioned divs angularjs
var mod;
mod = angular.module('infinite-scroll', []);
mod.directive('infiniteScroll', [
'$rootScope', '$timeout', function($rootScope, $timeout) {
return {
link: function(scope, elem, attrs) {
var checkWhenEnabled, handler, scrollDistance, scrollEnabled;
@clouddueling
clouddueling / stats.html
Created September 1, 2013 03:58
stats table befire directive was made angularjs
<tr>
<td
class='pointer'
ng-repeat='goal in main.goals'
ng-click='loadCenter(goal)'>
<div
ng-class='{
"grass-light": goal.progress >= 100,
"aqua-light": goal.progress < 100
}'
/**
* Thanks to @philsturgeon for pointing this package
* and Filipe Dobreira "https://github.com/filp" for creating it ^^
* Github : https://github.com/filp/whoops
* How to:
* Step 1 : Setup composer for Laravel 3
* Step 2 : Add this code to your application/start.php or anywhere u like
* as long its after laravel registers its own error handlers
* so NOT in : index.php, paths.php or laravel/**
*
@clouddueling
clouddueling / angularjs.html
Last active December 22, 2015 02:18
angularjs complex logic in template.
<div
ng-repeat='goal in userGoals[user.id]'
ng-class='{
"grass-light":
(
goal.recurrence == "daily" &&
goal.progress >= 100 &&
goal.timeframe.indexOf(main.day - 1) > -1
) ||
(
@clouddueling
clouddueling / script.js
Created August 27, 2013 03:24
editable redactor
$('.redactor-editable').on('click', function(){
var target = $(this).data('target'),
pk = $(this).data('pk'),
name = $(this).data('name'),
url = $(this).data('url');
if ($(this).html() == 'Save') {
var value = $(target).getCode();
$(target).destroyEditor();
@clouddueling
clouddueling / example1.php
Last active April 10, 2016 14:15
Long polling class
public function get_check($queue_id = 0)
{
$options = array(
'queue_id' => $queue_id
);
$status = Polling::forResult(function($options) {
$queue = Queue::find($options['queue_id']);
has_access($queue);
$chunks = array_chunk($mailgun_emails, 1000);
foreach ($chunks as $chunk) {
$emails = implode($chunk, ",");
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, 'api:frommyaccount');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
@clouddueling
clouddueling / highcharts.js
Last active December 21, 2015 07:19
highcharts directive
'use strict';
angular.module('highcharts',[])
.directive('chart', function () {
return {
restrict: 'E',
scope: {
data: "="
},