Skip to content

Instantly share code, notes, and snippets.

View craftfortress's full-sized avatar
:octocat:

Chris craftfortress

:octocat:
View GitHub Profile
@craftfortress
craftfortress / JSONP
Created February 27, 2013 19:52
Example JSONP Callback
$(document).ready(function () {
JSONP('http://URL.json?cb=JSONP');
function JSONP(URL) {
$.ajax({
url: URL,
dataType: 'jsonp',
data: {
@craftfortress
craftfortress / PayPal ASP.Net C#
Created March 2, 2013 11:53
PayPal ASP.Net C#
// create a new order and redirect to a payment page
protected void checkoutButton_Click(object sender, EventArgs e)
{
DataTable dt = ShoppingCartAccess.CreateOrder();
StringBuilder sb = new StringBuilder();
@craftfortress
craftfortress / PayPal ASP.Net C#
Created March 2, 2013 11:55
PayPal ASP.Net C#
// ASP .NET C#
using System;
using System.IO;
using System.Text;
using System.Net;
using System.Web;
public partial class csIPNexample : System.Web.UI.Page
{
<li id="author-bio-social-links" class="clr">
<a href="http://twitter.com/webdesigntunes" title="Twitter" target="_blank"><img src="http://www.webdesigntunes.com/wp-content/themes/web-
design/images/social/twitter.png" alt="Twitter"></a>
<a href="http://facebook.com/webdesigntunes" title="Facebook" target="_blank"><img src="http://www.webdesigntunes.com/wp-content/themes/web-
design/images/social/facebook.png" alt="Facebook"></a>
<a href="https://plus.google.com/u/1/117072715276995034167" title="Google Plus" target="_blank"><img src="http://www.webdesigntunes.com/wp-content/themes/web-
design/images/social/googleplus.png" alt="Google Plus"></a>
from datetime import datetime
import time
#-------------------------------------------------
# conversions to strings
#-------------------------------------------------
# datetime object to string
dt_obj = datetime(2008, 11, 10, 17, 53, 59)
date_str = dt_obj.strftime("%Y-%m-%d %H:%M:%S")
statusList = new SelectList(ListNotifications.GroupBy(p => p.Status, (key, g) => key));
@craftfortress
craftfortress / gist:87153b828a4e3a9c0364
Created September 24, 2014 14:03
Regex Remove HTML tags C#
Regex.Replace(Body, @"(\t|\n|\r|p?></?\w+)(?>(?:[^>'""]+|'[^']*'|""[^""]*"")*)>", "");
var Promise = require('bluebird');
// EXAMPLE 1
// EXAMPLE 1
// EXAMPLE 1
// ERROR HANDLER WILL CATCH REJECTION
function getPromise1(){
return new Promise(function(resolve, reject){
reject(new Error("Rejected error"))
}).then(function(result) {
/// REVERSE ARRAY
var array = [1,2,3,4,5,6,7,8,9];
var leftMark = 0;
var rightMark = array.length;
reverseArray(array,leftMark,rightMark);
function reverseArray(array, leftMark, rightMark){
function MyCustomError(message) {
this.message = message;
this.name = "MyCustomError";
Error.captureStackTrace(this, MyCustomError);
}
MyCustomError.prototype = Object.create(Error.prototype);
MyCustomError.prototype.constructor = MyCustomError;