Skip to content

Instantly share code, notes, and snippets.

Avatar

darius daftary radius

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am radius on github.
  • I am radiusradius (https://keybase.io/radiusradius) on keybase.
  • I have a public key ASCI3mciiym429J8Y6dW3tPZsjKkK7kHYkiJ6mty5W6z1go

To claim this, I am signing this object:

View xhr.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Simple XHR Example</title>
<script type="text/javascript">
function reqListener () {
var jsonResponse = JSON.parse(this.responseText);
var characters = jsonResponse.data.results;
View TodoListApp.jsx
import React, { Component } from 'react';
import './App.css';
class App extends Component {
render() {
return (
<TodoList />
)
}
}
View premailer_app.py
import premailer
def parse_template_tags(input_str):
""" Premailer encodes paths in the src attribute of images, so we have to swap them out w original values here """
mapping = (
('%7B%7B%20', '{{ '), ('%20%7D%7D', ' }}'),
('%7B%7B', '{{ '), ('%7D%7D', ' }}'),
)
for k, v in mapping:
View thing
https://jsfiddle.net/#&togetherjs=15bbxQITu0
@radius
radius / gist:9102288
Created Feb 19, 2014
AngularJS module for executing an expression when an element is shown
View gist:9102288
angular.module('OnShow', []).
directive('onShow', function () {
return {
controller: function($scope) {
$scope.fireOnce = false;
this.setFireOnce = function(bool) {
$scope.fireOnce = bool;
}
},
link: function(scope, elm, attr) {
@radius
radius / isOnScreen.jqery.js
Created Aug 20, 2013
jquery function to tell if a dom element is within the viewport
View isOnScreen.jqery.js
$.fn.isOnScreen = function(){
var win = $(window);
var viewport = {
top : win.scrollTop(),
left : win.scrollLeft()
};
viewport.right = viewport.left + win.width();
viewport.bottom = viewport.top + win.height();
var bounds = this.offset();
@radius
radius / Default.sublime-theme
Created Nov 5, 2012
My Sublime Text 2 default theme (Packages/Theme - Default/Default.sublime-theme)
View Default.sublime-theme
[
{
"class": "label_control",
"color": [255, 255, 255],
"shadow_color": [24, 24, 24],
"shadow_offset": [0, -1]
},
{
"class": "button_control",
"content_margin": [6, 5, 6, 6],
@radius
radius / urlparams.js
Created Jul 30, 2012
Get URL Query String Parameters with Javascript
View urlparams.js
var urlParams = (function () {
var _params={},
e,
a = /\+/g, // Regex for replacing addition symbol with a space
r = /([^&=]+)=?([^&]*)/g,
d = function (s) { return decodeURIComponent(s.replace(a, " ")); },
q = window.location.search.substring(1);
while (e = r.exec(q)) {
_params[d(e[1])] = d(e[2]);
@radius
radius / inputPlaceholder.jquery.js
Created May 16, 2012
Input Placeholder jQuery Plugin
View inputPlaceholder.jquery.js
$.fn.inputPlaceholder = function(options){
return $(this).each(function() {
var options = jQuery.extend({
text: $(this).attr('placeholder')
},options);
if($(this).val() == '') {
$(this).val(options.text);
}
$(this)