Skip to content

Instantly share code, notes, and snippets.

View phaniram's full-sized avatar

Maturu Srinivas Phani Ram phaniram

View GitHub Profile
@erichurst
erichurst / database.yml.example mysql2
Created May 9, 2011 02:58
Rails 3 database.yml examples
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
@rrobe53
rrobe53 / gist:976610
Created May 17, 2011 14:46
Node.js File Extension Content Type
exports.ext = function () {
var extTypes = {
"3gp" : "video/3gpp"
, "a" : "application/octet-stream"
, "ai" : "application/postscript"
, "aif" : "audio/x-aiff"
, "aiff" : "audio/x-aiff"
, "asc" : "application/pgp-signature"
, "asf" : "video/x-ms-asf"
, "asm" : "text/x-asm"
@mhawksey
mhawksey / gist:1276293
Last active October 23, 2023 09:00
Google App Script to insert data to a google spreadsheet via POST or GET - updated version as per https://mashe.hawksey.info/2014/07/google-sheets-as-a-database-insert-with-apps-script-using-postget-methods-with-ajax-example/
/*
Copyright 2011 Martin Hawksey
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@phaniram
phaniram / Solution.java
Created December 28, 2011 18:28
Interview Street Challenges-String reduction
package interviewstreet;
import java.util.Arrays;
import java.util.Scanner;
public class Solution {
int min=1;
int val=1;
public static void main(String[] args) {
@Dither
Dither / cssify.js
Created February 25, 2012 17:38
Convert XPath to CSS selector
// JavaScript function for converting simple XPath to CSS selector.
// Ported by Dither from [cssify](https://github.com/santiycr/cssify)
// Example: `cssify('//div[@id="girl"][2]/span[@class="body"]//a[contains(@class, "sexy")]//img[1]')`
var sub_regexes = {
"tag": "([a-zA-Z][a-zA-Z0-9]{0,10}|\\*)",
"attribute": "[.a-zA-Z_:][-\\w:.]*(\\(\\))?)",
"value": "\\s*[\\w/:][-/\\w\\s,:;.]*"
};
@phaniram
phaniram / spoon.java
Created March 2, 2012 19:02
Codechef-MarchContest-SPOON-(Accepted)
package com.cyp.codechef.marcontest;
import java.io.IOException;
import java.util.Scanner;
/*
* Cypronmaya - Codechef March 2012 Contest - Problem Code : SPOON
*/
class SPOON {
@BinaryMuse
BinaryMuse / phantom.coffee
Created April 13, 2012 18:33
Take screenshots with Phantom.js from Node.js
#!/usr/bin/env coffee
# Call the program with: coffee phantom.coffee http://url.to/screengrab
phantom = require 'phantom' # npm install phantom
child_process = require 'child_process'
url = process.argv[2]
createScreenshot = (page, filename) ->
@latortuga
latortuga / gist:4241729
Created December 8, 2012 20:13
Setup Uploadify to upload directly to S3
var uploadify_data = {
'AWSAccessKeyId': '<%= @uploadify_data[:access_key] %>',
'bucket': '<%= @uploadify_data[:bucket] %>',
'acl': 'private',
'key': '<%= @uploadify_data[:key] %>${filename}',
'signature': '<%= @uploadify_data[:signature] %>',
'policy': '<%= @uploadify_data[:policy] %>',
'success_action_status': '<%= @uploadify_data[:sas] %>',
'folder': '',
'Filename': ''
@phaniram
phaniram / Cssify.java
Created March 24, 2013 07:16
Convert XPath to CSS selector
// Java function for converting simple XPath to CSS Selector.
// Used cssify.js from [cssify.js](https://gist.github.com/Dither/1909679)
// Removed log statements (as window objects aren't supported in ScriptEngine)
import java.io.FileNotFoundException;
import java.io.FileReader;
import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
@OneCricketeer
OneCricketeer / main.js
Last active January 25, 2022 06:36
Targeted Push Notifications: Parse.com Cloud Code
// Use Parse.Cloud.define to define as many cloud functions as you want.
// For example:
Parse.Cloud.define("hello", function(request, response) {
response.success("Hello world!");
});
Parse.Cloud.define("userWithEmailExists", function(request, response) {
var email = request.params.email;
if (email != null && email !== "") {
email = email.trim();