Skip to content

Instantly share code, notes, and snippets.

@gabhi
gabhi / gist:dbe44ef5e638357399cc
Last active August 28, 2015 18:52
unix stuff
sudo chown -R $(whoami) . //change owner for given folder recursively
find /opt/ais -user root //find all directories whose owner is user Root
@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);
@gabhi
gabhi / gist:9779334
Created March 26, 2014 09:08
array in php
$response = array();