Skip to content

Instantly share code, notes, and snippets.

@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@thom4parisot
thom4parisot / casper-dump-headers.js
Created July 17, 2012 13:58
Dump Response Headers with CasperJS
var casper = require('casper').create();
casper.start();
casper.open('http://borisschapira.com/');
casper.then(function dumpHeaders(){
this.currentResponse.headers.forEach(function(header){
console.log(header.name +': '+ header.value);
});
});
@markstreich
markstreich / gist:3667944
Created September 7, 2012 17:27
PhantomJS: Ajax response capture through console.log
var page = require('webpage').create();
page.open('http://www.website.com/', function (status) {
if (status === 'success') {
captureAjaxResponsesToConsole();
}
});
function captureAjaxResponsesToConsole() {
// logs ajax response contents to console so sublime's onConsoleMessage can use the contents
var Util = require('util');
var Https = require('https');
var Tls = require('tls');
/**
* HTTPS Agent for node.js HTTPS requests via a proxy.
* blog.vanamco.com/connecting-via-proxy-node-js/
*/
function HttpsProxyAgent(options)
{
@erickoledadevrel
erickoledadevrel / xmlToJson.js
Created December 1, 2014 14:30
A function to convert an XML string to a JSON object in Apps Script, using logic similar to the sunset method Xml.parse().
/**
* Converts an XML string to a JSON object, using logic similar to the
* sunset method Xml.parse().
* @param {string} xml The XML to parse.
* @returns {Object} The parsed XML.
*/
function xmlToJson(xml) {
var doc = XmlService.parse(xml);
var result = {};
var root = doc.getRootElement();
@robertbrook
robertbrook / protestation-records-matched.geojson
Created February 4, 2015 18:18
protestation-records-matched.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rain1024
rain1024 / tut.md
Last active June 11, 2024 19:27
Install pdflatex ubuntu

PdfLatex is a tool that converts Latex sources into PDF. This is specifically very important for researchers, as they use it to publish their findings. It could be installed very easily using Linux terminal, though this seems an annoying task on Windows. Installation commands are given below.

  • Install the TexLive base
sudo apt-get install texlive-latex-base
  • Also install the recommended and extra fonts to avoid running into the error [1], when trying to use pdflatex on latex files with more fonts.
@mhawksey
mhawksey / quickstart.html
Created October 2, 2015 15:24
Google Sheets as a Database – Authenticated INSERT with Apps Script using Execution API - Working Example
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<title>Google Sheets as a Database – Authenticated INSERT with Apps Script using Execution API - Working Example</title>
<script type="text/javascript">
// Your Client ID can be retrieved from your project in the Google
// Developer Console, https://console.developers.google.com
var CLIENT_ID = '<INSERT_YOUR_CLIENT_ID>';
var SCRIPT_ID = '<INSERT_YOUR_SCRIPT_ID>';
@nikmartin
nikmartin / twiml.gs
Created November 9, 2015 21:38
Google Apps Script to produce Twilio TWIML
function doGet(e) {
var toNum = e.parameter.PhoneNumber;
var fromNum = e.parameter.CallerId;
var action = e.parameter.Direction;
var record = e.parameter.Record;
Logger.log(e);
var output = ContentService.createTextOutput();
var xml = createDialTWIML(fromNum, toNum, action);
@anubhavshrimal
anubhavshrimal / CountryCodes.json
Last active June 14, 2024 06:38 — forked from Goles/CountryCodes.json
Country and Dial or Phone codes in JSON format
[
{
"name": "Afghanistan",
"dial_code": "+93",
"code": "AF"
},
{
"name": "Aland Islands",
"dial_code": "+358",
"code": "AX"