This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ActionResult Read([DataSourceRequest]DataSourceRequest, int item_id){ | |
DataSourceResult audits = logs.ToDataSourceResult(request, audit => new AuditDTO{ | |
id = audit.id | |
}); | |
System.Collections.IEnumerable items = audits.Data; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_ip_address() { | |
$ip_keys = array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR'); | |
foreach ($ip_keys as $key) { | |
if (array_key_exists($key, $_SERVER) === true) { | |
foreach (explode(',', $_SERVER[$key]) as $ip) { | |
// trim for safety measures | |
$ip = trim($ip); | |
// attempt to validate IP | |
if (validate_ip($ip)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//http://stackoverflow.com/questions/470617/get-current-date-and-time-in-php | |
//code below is from stackoverflow | |
$now = new DateTime(); | |
echo $now->format('Y-m-d H:i:s'); // MySQL datetime format | |
echo $now->getTimestamp(); // Unix Timestamp | |
$now = new DateTime(null, new DateTimeZone('America/New_York')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
// The email address notifications should be sent to | |
$____email_address = 'contact@twitapps.com'; | |
// This array maps incoming emails to scripts | |
$____processor_map = array( | |
// For the ta_follows user there's a separate script for each notification type | |
'ta_follows' => array( | |
'is_following' => dirname(__FILE__).'/ta_follows/new_follower.php', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
// The email address notifications should be sent to | |
$____email_address = 'contact@twitapps.com'; | |
// This array maps incoming emails to scripts | |
$____processor_map = array( | |
// For the ta_follows user there's a separate script for each notification type | |
'ta_follows' => array( | |
'is_following' => dirname(__FILE__).'/ta_follows/new_follower.php', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function random_text( $type = 'alnum', $length = 8 ) | |
{ | |
switch ( $type ) { | |
case 'alnum': | |
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; | |
break; | |
case 'alpha': | |
$pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; | |
break; | |
case 'hexdec': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require("Services/Twilio.php"); | |
require("database.php"); | |
// require POST request | |
if ($_SERVER['REQUEST_METHOD'] != "POST") die; | |
// generate "random" 6-digit verification code | |
$code = rand(100000, 999999); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('DOMContentLoaded', function () { | |
document.getElementById('save').addEventListener('click', save_options); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Typeahead by Charles Lawrence https://gist.github.com/1848558--> | |
<script type="text/javascript"> | |
var autocomplete = $('.typeahead').typeahead().on('keyup', function(ev){ | |
ev.stopPropagation(); | |
ev.preventDefault(); | |
//filter out up/down, tab, enter, and escape keys | |
if( $.inArray(ev.keyCode,[40,38,9,13,27]) === -1 ){ | |
var self = $(this); | |
//set typeahead source to empty | |
self.data('typeahead').source = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set expires header and Remove ETags | |
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)(\.gz)?$"> | |
Header set Expires "Thu, 15 Apr 2012 20:00:00 GMT" | |
Header unset ETag | |
FileETag None | |
</FilesMatch> | |
# Set cache-control header | |
<FilesMatch "\.(ico|jpg|png|gif)(\.gz)?$"> | |
Header set Cache-Control "public" |