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
package hello | |
import ( | |
"net/http" | |
"github.com/go-martini/martini" | |
"github.com/martini-contrib/cors" | |
"github.com/martini-contrib/render" | |
"math/rand" | |
) | |
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
// Load the http module to create an http server. | |
var http = require('http'); | |
// Create a function to handle every HTTP request | |
function handler(req, res){ | |
var form = ''; | |
if(req.method == "GET"){ | |
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
{{if eq .authuser.Id .user.Id }}<button type="button" class="delete_user" rel="{{.user.Id}}">Delete My Account</button>{{end}} |
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
var casper = require('casper').create({ | |
verbose: true, | |
logLevel: 'debug', | |
pageSettings: { | |
loadImages: true, | |
loadPlugins: true, | |
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4' | |
} | |
}); |
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
type Post struct { | |
// db tag lets you specify the column name if it differs from the struct field | |
Id int64 `db:"post_id"` | |
Created int64 | |
Title string `form:"Title" binding:"required"` | |
Body string `form:"Body"` | |
UserId int64 `form:"UserId"` | |
Url string | |
} |
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
/* | |
Assuming jQuery Ajax instead of vanilla XHR | |
*/ | |
//Get Github Authorization Token with proper scope, print to console | |
$.ajax({ | |
url: 'https://api.github.com/authorizations', | |
type: 'POST', | |
beforeSend: function(xhr) { | |
xhr.setRequestHeader("Authorization", "Basic " + btoa("USERNAME:PASSWORD")); |
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
<input type="file" name="file" id="file"> | |
<input type="submit" id="submit" name="Upload" onclick="upload();return false;"> | |
<script type="text/javascript"> | |
function upload(){ | |
var formData = new FormData(); | |
formData.append("action", "upload-attachment"); | |
var fileInputElement = document.getElementById("file"); | |
formData.append("async-upload", fileInputElement.files[0]); |
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 | |
if ( !defined('SAVEQUERIES') && isset($_GET['debug']) && $_GET['debug'] == 'sql' ) | |
define('SAVEQUERIES', true); | |
if ( !function_exists('dump') ) : | |
/** | |
* dump() | |
* |
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 | |
//error_reporting(E_ALL); | |
//var_dump($_SERVER); | |
$post_data = $_POST['data']; | |
if (!empty($post_data)) { | |
$dir = 'YOUR-SERVER-DIRECTORY/files'; | |
$file = uniqid().getmypid(); | |
$filename = $dir.$file.'.txt'; | |
$handle = fopen($filename, "w"); | |
fwrite($handle, $post_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 | |
//based on Wordpress Multiple Insert https://github.com/mirzazeyrek/wordpress-multiple-insert | |
function wp_insert_update_rows($row_arrays = array(), $wp_table_name) { | |
global $wpdb; | |
$wp_table_name = esc_sql($wp_table_name); | |
$update = ""; | |
$query = ""; | |
$query_columns = ""; | |
$query. = "INSERT INTO {$wp_table_name} ("; |
NewerOlder