Skip to content

Instantly share code, notes, and snippets.

View attomos's full-sized avatar
💆‍♀️

Nattaphoom Chaipreecha attomos

💆‍♀️
View GitHub Profile
@attomos
attomos / jscall.php
Created January 9, 2012 09:02
Call javascript function from PHP
<script>
function a() {
alert("This is msg.");
}
</script>
<?php
$a = 1;
if ($a == 2) {
} else {
@attomos
attomos / .profile
Created January 20, 2012 13:22
My .profile backup
# MacPorts Installer addition on 2011-01-05_at_00:44:12: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# define colors
C_DEFAULT="\[\033[m\]"
C_WHITE="\[\033[1m\]"
C_BLACK="\[\033[30m\]"
C_RED="\[\033[31m\]"
C_GREEN="\[\033[32m\]"
C_YELLOW="\[\033[33m\]"
@attomos
attomos / gist:2555428
Created April 30, 2012 04:18 — forked from GeorgeErickson/gist:1134831
webfaction ssh
The procedure for setting up automatic private/public key login on our servers is as follows:
- On your own machine, go to $HOME/.ssh and type: ssh-keygen -t dsa
- When prompted for it, leave the default location for the file and let the passphrase empty
- Copy the content of the "id_dsa.pub" file that just got created into the $HOME/.ssh/authorized_keys and authorized_keys2 on our machine.
- Set the following permissions:
chmod 644 $HOME/.ssh/authorized_keys*
@attomos
attomos / dosomething.sh
Created September 1, 2012 17:40
Execute shell script or python script on startup (Ubuntu). Assume that you save dosomething.sh at ~/Desktop
#!/bin/bash
echo "Really do some thing"
@attomos
attomos / assignment_13_output
Created November 18, 2012 16:25
assignment 13 output
This file has been truncated, but you can view the full file.
8 Heart is picked
Q Club is picked
8 Spade is picked
Your sum: 28
A Heart is picked
9 Spade is picked
5 Spade is picked
Computer sum: 15
@attomos
attomos / gist:4177672
Created November 30, 2012 18:45
Excerpt from my Family Tree
/**
* Prints all of ancestors of the given `full_name`, `level` is used
* for indicates the level of ancestors.
*/
void FamilyLinkedList::PrintAncestors(string full_name, int level) {
FamilyNode *person = Get(full_name);
// base case
if (person == NULL || full_name.compare(kNotIdentified) == 0) {
return;
}
@attomos
attomos / Molokai.itermcolors
Created June 19, 2013 15:47 — forked from netmute/Molokai.itermcolors
Good combination with eval `gdircolors paht/to/dircolors-solarized/dircolors.ansi-universal`
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.48771023750305176</real>
<key>Green Component</key>
<real>0.48781105875968933</real>

Postman - REST Client with OAuth2orize

For this to work you will need to install the Postman - REST Client for some of these steps. Of course you will need to install OAuth2orize as well.

Run the oauth2orize provider/server example which does server-side OAuth flow:

cd oauth2orize\examples\express2
node app.js
app.configure(function () {
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser());
app.configure('production', function () {
app.use (function (req, res, next) {
var schema = (req.headers['x-forwarded-proto'] || '').toLowerCase();
if (schema === 'https') {
var application_root = __dirname,
express = require("express"),
path = require("path"),
mongoose = require('mongoose');
var app = express.createServer();
// database
mongoose.connect('mongodb://localhost/ecomm_database');