Skip to content

Instantly share code, notes, and snippets.

View applehat's full-sized avatar
✝️
Sola Fide

Cameron Chunn applehat

✝️
Sola Fide
View GitHub Profile
@applehat
applehat / gist:3166446
Created July 23, 2012 21:49
php hello world
<?php
echo "hello world";
?>
@applehat
applehat / twitter.hashtagify.js
Created July 24, 2012 01:44
Twitter Hashtagify
/*
* Accepts any string, and returns a twitter hastag of that string
* @text - String to convert to a hashtag
*/
function makeHashTag(text) {
var v = text.replace(/[^a-z0-9]/gi, '');
if (!isNaN(v[0])) {
var fixtr = "num";
switch (v[0]) {
@applehat
applehat / gist:3170393
Created July 24, 2012 14:48
jQuery Ajax example for PHP-XSS
var request = $.ajax({
url: "/url/to/your/xss.php",
data: {url : 'http://www.google.com/ig/api?weather=Mountain+View'},
dataType: "xml"
});
request.done(function(xml) {
var weather = $(xml).find("current_conditions > condition").attr('data');
alert('It is '+weather+' in Mountain View');
});
<?php
/* accepts date as a unix timestamp, a string, or empty for today. */
function is_caturday($date=null)
{
if (is_numeric($date) && $date !== null) {
$time = $date;
} elseif($date !== null) {
$time = strtotime($date);
@applehat
applehat / alloy.js
Last active December 11, 2015 06:28
Alloy.Globals.settings = {}; // Create Empty Object.
/* Settings Getter - Can also just access Alloy.Globals.settings[key] */
Alloy.Globals.settings.get = function(key) {
return Alloy.Globals.settings[key] || null;
}
/* Settings Saver */
Alloy.Globals.settings.set = function(key,value) {
var settings = Alloy.createCollection('settings');
@applehat
applehat / garbage.js
Last active December 14, 2015 01:49
Recursively kill elements in Alloy with Global Function.
Alloy.Globals.gc = function(ob, parent) {
if (ob.children) {
for (var c = (ob.children.length - 1); c >= 0; c--) {
Alloy.Globals.gc(ob.children[c], ob);
}
}
if (parent) {
parent.remove(ob);
ob = null;
}
<?php
$original = $some_variable;
$length = 100;
echo (strlen($original) > $length)?substr($original,0,$length)."...":$original;
?>
87.106.81.107 - - [23/Jan/2013:17:11:55 -0600] "GET /webcalendar/install/index.php HTTP/1.1" 404 2011
87.106.81.107 - - [23/Jan/2013:17:11:55 -0600] "GET /suspended.page/ HTTP/1.1" 200 3448
112.90.138.183 - - [23/Jan/2013:17:13:18 -0600] "GET / HTTP/1.1" 200 116
168.62.202.45 - - [23/Jan/2013:17:13:41 -0600] "GET /men-s-canada-goose-lodge-down-hoody-gray HTTP/1.1" 404 2049
168.62.202.45 - - [23/Jan/2013:17:13:42 -0600] "GET /cgi-sys/defaultwebpage.cgi HTTP/1.1" 200 3477
95.108.150.235 - - [23/Jan/2013:17:14:46 -0600] "GET /robots.txt HTTP/1.1" 404 1977
95.108.150.235 - - [23/Jan/2013:17:14:48 -0600] "GET /cgi-sys/defaultwebpage.cgi HTTP/1.1" 200 1682
@applehat
applehat / TableCrusher.js
Last active May 9, 2016 21:15
Crush tables that won't get out of the way of themselves.
$(function(){
$("<style type='text/css'> .crushedTable { table-layout:fixed } .crushMe { text-overflow: ellipsis; white-space: nowrap; overflow: hidden; padding: 0 !important; } </style>").appendTo("head");
tableCrusher(); // run first thing, because we dont need a resize to be broken.
var tableCrusherRTime;
var tableCrushertableCrusherTimeout = false;
var tableCrusherDelta = 200;
$(window).resize(function() {
tableCrusherRTime = new Date();
if (tableCrusherTimeout === false) {
### Keybase proof
I hereby claim:
* I am applehat on github.
* I am applehat (https://keybase.io/applehat) on keybase.
* I have a public key ASBvbRdcl-5Fz2bhd0dJoXbZh2Loc1eFhbOHKny5kqpcOgo
To claim this, I am signing this object: