Skip to content

Instantly share code, notes, and snippets.

@gabhi
gabhi / test
Created August 8, 2012 07:45
test
sdf
public class Solution {
public ArrayList<String> anagrams(String[] strs) {
// Start typing your Java solution below
// DO NOT write main() function
if(strs.length < 2) return new ArrayList();
HashMap<String, ArrayList<String>> map = new HashMap();
for(String str : strs) {
String key = sortChars(str);
@gabhi
gabhi / gist:9735248
Last active August 29, 2015 13:57
ionic side menu
<ion-side-menus>
<!-- Center content -->
<ion-pane ion-side-menu-content>
<header class="bar bar-header bar-positive">
<button class="button button-icon" ng-click="toggleMenu()">
Left
</button>
<h1 class="title">Center</h1>
<button class="button button-clear" ng-click="toggleRight()">
@gabhi
gabhi / gist:9755243
Created March 25, 2014 04:23
web page scraping using request cheerio nodejs
var request = require('request');
var cheerio = require('cheerio');
var searchTerm = 'screen+scraping';
var url = 'http://www.bing.com/search?q=' + searchTerm;
request(url, function(err, resp, body){
$ = cheerio.load(body);
links = $('.sb_tlst h3 a'); //use your CSS selector here
$(links).each(function(i, link){
@gabhi
gabhi / gist:9773396
Last active August 29, 2015 13:57
dropdown (select) using angular js
<select ng-model="selectedOption" ng-options="todo._id as todo.name for todo in todos"></select><br>
@gabhi
gabhi / gist:9778492
Created March 26, 2014 07:52
php allow cross origin response
header('Access-Control-Allow-Origin: *');
@gabhi
gabhi / gist:9779286
Created March 26, 2014 09:06
php wordpress api -- json conversion
<?php
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
require_once('wp-load.php');
$response = array();
if(isset($_GET['post_id'])) {
@gabhi
gabhi / gist:9779302
Created March 26, 2014 09:06
get wordpress post by id
$mypost = get_post($_GET['post_id']);
@gabhi
gabhi / gist:9779311
Created March 26, 2014 09:07
get root categories for wordpress
$root_categories = get_categories( array(
'parent' => 0,
) );
@gabhi
gabhi / gist:9779327
Created March 26, 2014 09:08
get subcategories of wordpress category
$args = array(
'child_of' => $_GET['id']
);
$sub_categories = get_categories($args);