Skip to content

Instantly share code, notes, and snippets.

View motyar's full-sized avatar
🟢
I may be slow to respond.

Motyar motyar

🟢
I may be slow to respond.
View GitHub Profile
@motyar
motyar / index.html
Created September 26, 2014 13:10
Redirect to new domain with only JavaScript
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<script>
(function(){
var url = window.location.href;
console.log(url.split('/'));
var newUrl = url.replace(url.split('/')[2],"newdomain.com");
s
{
"Ok":12
}
@motyar
motyar / main.go
Last active November 13, 2015 21:09 — forked from maxmcd/main.go
Gitbaotest
package main
import (
"fmt"
"net/http"
"time"
)
func main() {
http.HandleFunc("/",
4107632
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script>
<script type="text/javascript" src="https://raw.githubusercontent.com/abdmob/x2js/master/xml2json.min.js" charset="UTF-8"></script>
<meta charset="utf-8">
<title>Parsing XML in ajgularJS</title>
</head>
<body ng-app="todosApp">
<h2>Parsing XML data with AngularJS</h2>
@motyar
motyar / 1456800856.csv
Last active March 1, 2016 03:04 — forked from anonymous/1456800856.csv
Another gist
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 14 columns, instead of 10 in line 5.
Name,"Street Address",City,State,"Zip code",Phone,Website,Rating,Reviews,"Merchant Verified","Zagat Score",Lat,Lon,"Listing URL"
"Cesare Bistro","1126 Malvern Rd, Malvern VIC 3144, Australia",,Victoria,3144,"+61 3 9824 8126",,,,,,-37.8518021,145.0305495,https://maps.google.com/?cid=331980050335729601
"The Feed Bag Cafe","1129 Malvern Rd, Malvern VIC 3144, Australia",,Victoria,3144,"+61 3 9822 2147",,,2,,,-37.8515806,145.0303308,https://maps.google.com/?cid=9348602243163246040
"Ionsky's Bakehouse Cafe","1125 Malvern Rd, Malvern VIC 3144, Australia",,Victoria,3144,"+61 3 9822 1618",,,4,,,-37.851526,145.030218,https://maps.google.com/?cid=2678506672615980113
"Coles Express Glenvern","Malvern Rd, Malvern VIC 3144, Australia",,Victoria,3144,"+61 3 9822 1481",http://www.colesexpress.com.au/,,1,,,-37.851869,145.02967,https://maps.google.com/?cid=11935115476390218234
"The Malvern Hotel","Malvern Rd &amp; Glenferrie Rd, Toorak VIC 3144, Australia",,Victoria,3144,"+61 3 9822 3582",http://www.themalvern.com/contact,,3,
package main
import(
"flag"
"fmt"
"net/http"
"strings"
"io/ioutil"
"encoding/json"
"gopkg.in/mgo.v2/bson"
@motyar
motyar / events.php
Created August 23, 2016 02:24
Slack API event handler in PHP
<?php
header('Content-Type: application/x-www-form-urlencoded');
$entityBody = file_get_contents('php://input');
echo $entityBody;
// DO things with Slack API + $entityBody HERE!
?>
@motyar
motyar / login.php
Last active August 10, 2018 12:12
Login with Facebook ( In 20 lines of PHP code )
<?php
// Set $apiVersion, $apiSecret, $redirectUrl, and $scope etc here.
if($_GET['logout']!=""){
session_destroy();
exit("Logged out");
}
if($_GET['code']!=""){
$accessData = json_decode(file_get_contents("https://graph.facebook.com/".$apiVersion."/oauth/access_token?client_id=".$appId."&redirect_uri=".$redirectUrl."&client_secret=".$appSecret."&code=".trim($_GET['code'])),true);
$userInfo = json_decode(file_get_contents("https://graph.facebook.com/v2.7/me?fields=email,id,name&access_token=".$accessData['access_token']),true);
$_SESSION['access'] = $userInfo;