Skip to content

Instantly share code, notes, and snippets.

View adityamenon's full-sized avatar

Aditya MP adityamenon

View GitHub Profile
@adityamenon
adityamenon / test.js
Created March 27, 2016 15:46
Suggested signup code on deepstream.io
$scope.execSignup = function () {
var fullName = $scope.signupForm.FullName,
username = $scope.signupForm.Username,
password = $scope.signupForm.Password;
dsanon.on('error', function (err) {
console.log("Anonymous Deepstream connection error: ", err);
});
var newUserRecord = dsanon.record.getRecord("user/"+username)
@adityamenon
adityamenon / index.js
Last active January 4, 2016 16:32 — forked from PhilKershaw/gist:2171814
Simple example of using 2-legged OAuth in Node.js (requires node-oauth)
var express = require('express');
var oauth = require('oauth');
var sys = require('sys');
var app = express.createServer();
var key = "[api-key]";
var secret = "[api-secret]";
var request = new oauth.OAuth(null, null, key, secret, '1.0', null, 'HMAC-SHA1');
app.get('/api-request', function(req, res){
request.get(
@adityamenon
adityamenon / petstore.yaml
Created July 30, 2015 12:04
The REAL Swagger Pet Store YAML
# Google search for Swagger Petstore YAML returns a link to https://github.com/swagger-api/swagger-spec/blob/master/examples/v2.0/yaml/petstore.yaml
# But this isn't the full story. Got the output below by translating the JSON http://petstore.swagger.io/v2/swagger.json with http://jsontoyaml.com/
---
swagger: "2.0"
info:
description: "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters."
version: "1.0.0"
title: "Swagger Petstore"
termsOfService: "http://swagger.io/terms/"
contact:
@adityamenon
adityamenon / testTopiaTermextractor.py
Last active August 29, 2015 14:10
Testing out the Python topia termextract package.
#!/usr/bin/env python
from topia.termextract import extract
text = '''
My Career Objectives:
Build impactful applications.
Work on a diverse range of technologies and platforms.
Have fun doing it all.

We are gonna be using php5.5 , so upgrade your systems to that.

  1. http://laravel.com/docs/contributing#coding-guidelines , we follow these, along with PSR-0 and PSR-1.

  2. use Foo (aliasing) etc statements should start from the 3rd line. Each class that needs to be used in a namespace has to be aliased in a separate line.

  3. Aliasing is important. You shouldn't be using more than two Namespace Separators (\) in the code that you right in your classes. Try to restrict the count of those namespace separators to one.

  4. No accessing global namespace (ie, \Foo is not allowed, you need to alias the class Foo via use Foo). The only exception for this is php spl exception classes.

We are gonna be using php5.5 , so upgrade your systems to that.

  1. http://laravel.com/docs/contributing#coding-guidelines , we follow these, along with PSR-0 and PSR-1.

  2. use Foo (aliasing) etc statements should start from the 3rd line. Each class that needs to be used in a namespace has to be aliased in a separate line.

  3. Aliasing is important. You shouldn't be using more than two Namespace Separators (\) in the code that you right in your classes. Try to restrict the count of those namespace separators to one.

  4. No accessing global namespace (ie, \Foo is not allowed, you need to alias the class Foo via use Foo). The only exception for this is php spl exception classes.

@adityamenon
adityamenon / app.domainname
Last active December 28, 2021 06:31
My preferred configuration for a Laravel 4 API endpoint running over PHP-FPM, when I need to talk to it with AngularJS.
server {
root /path/to/app/public;
index index.php;
server_name test.dev;
set $cors_headers "whatever-custom-headers,you-would-like";
# redirection to index.php
location / {
try_files $uri $uri/ /index.php?$query_string;
@adityamenon
adityamenon / Default (linux).sublime-keymap
Created August 5, 2013 16:22
My Sublime Text 3 settings. Nothing fancy.
[
{ "keys": ["ctrl+tab"], "command": "next_view" },
{ "keys": ["ctrl+shift+tab"], "command": "prev_view" },
{ "keys": ["shift+delete"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Line.sublime-macro"} },
]
@adityamenon
adityamenon / upload_controller.php
Created July 31, 2012 05:58
Codeigniter upload a dynamic number of files
<?php if(!defined('BASEPATH')) exit("No direct script access allowed.");
class Upload_test extends CI_Controller {
public function index() {
if($this->input->post('submit')) {
$config['upload_path'] = BASEPATH.'../uploads';
$config['allowed_types'] = 'txt';
@adityamenon
adityamenon / .htaccess.example
Created July 2, 2012 01:57
.htaccess for CodeIgniter setups - remove index.php and other stuff
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
### Canonicalize codeigniter URLs
# If your default controller is something other than
# "welcome" you should probably change this
# RewriteRule ^(home(/index)?|index(\.php)?)/?$ / [L,R=301]