Skip to content

Instantly share code, notes, and snippets.

@Rinlama
Rinlama / folder as repository and push to git
Created July 2, 2015 14:23
Make a folder repository and push to git
cd <localdir>
git init
git add .
git commit -m 'message'
git remote add origin <url>
git push -u origin master
@Rinlama
Rinlama / feature image query
Last active August 29, 2015 14:24
Query on Database wordpress with pagination and featured image query
<?php
$args = array(
'post_type' => 'Custom_Blog',
'posts_per_page' => 6
);
$the_query=new WP_Query($args);
while ( $the_query->have_posts() ) {
PrintWriter objOutStream = new PrintWriter(new BufferedWriter(new FileWriter("EmployeeData.txt"))); //create and wite on object data . get the hashEmployee//
for (Map.Entry<String, Employee> entry : hashEmployeelist.entrySet()) {
String key = entry.getKey();
Employee employeeobj = entry.getValue();
objOutStream.println(employeeobj.getSsNumber() + "," + employeeobj.getFirstName() + "," + employeeobj.getLastName() + "," + employeeobj.getDateOfBirth() + "," + employeeobj.getAddress() + "," + employeeobj.getPhone() + "," + employeeobj.getEmail() + "," + employeeobj.getJobTitle());
}
objOutStream.close();
@Rinlama
Rinlama / Python inside a PHP code
Created July 9, 2015 22:15
Python inside a PHP code
<?php
$command = escapeshellcmd('python /users/rinjin/desktop/webscrap.py');
$output = shell_exec($command);
echo $output;
?>
@Rinlama
Rinlama / web scraping
Created July 9, 2015 22:27
python web scraping
import urllib
import re
urls=["http://google.com","http://nytimes.com","http://cnn.com","http://facebook.com","http://youtube.com"]
regex='<title>(.+?)</title>'
pattern= re.compile(regex)
for x in urls:
htmlfile =urllib.urlopen(x)
@Rinlama
Rinlama / error printing
Created July 14, 2015 19:21
Find error on Php
ini_set( 'error_reporting', E_ALL );
ini_set( 'display_errors', true );
@Rinlama
Rinlama / Rest Api
Created July 14, 2015 19:22
Rest Api on Php
<?php
if (!empty($_GET['location'])){
/**
* Here we build the url we'll be using to access the google maps api
*/
$maps_url = 'https://'.
'maps.googleapis.com/'.
'maps/api/geocode/json'.
'?address=' . urlencode($_GET['location']);
$maps_json = file_get_contents($maps_url);
@Rinlama
Rinlama / BX slider custom silde with thumbnail
Created July 16, 2015 16:25
BX slider custom silde with thumbnail on wordpress
<div class="col-md-5 col-xs-12">
<h2><em>Latest Troll Nepal</em></h2>
<br/>
<?php
$listcontent=array();
$listthumbnail=array();
$count=0;
$the_query=new WP_Query('post_type=TrollNepal');
@Rinlama
Rinlama / Crul method
Created July 20, 2015 15:16
Crul method to do a Instagram Hash tag
<?php
function callInstagram($url)
{
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => 2
));
@Rinlama
Rinlama / close server
Created July 21, 2015 17:25
Closer server on background
In the terminal run fg
Press Control-C (if on a mac)