Skip to content

Instantly share code, notes, and snippets.

<?php
$user = 'hayat';
$pass = '123456';
// don't forget to use double quote
$ret = shell_exec("bash test.sh $user $pass");
// return will print output from that bash script, you may not need to print return if you don't want.
@ambross
ambross / custom-post-taxonomy-permalinks.php
Created May 28, 2017 20:37 — forked from kasparsd/custom-post-taxonomy-permalinks.php
Create permalink structure URLs for custom post types that include all parent terms from a custom taxonomy
<?php
/*
Term Archive Pages:
- http://example.com/recipes/dinner/
- http://example.com/recipes/breakfast,brunch/
Single Recipe Pages:
- http://example.com/recipes/dinner/soup-title/
@ambross
ambross / supervisor.conf
Created February 28, 2017 19:36 — forked from hezhao/myapp.conf
Example supervisor config file /etc/supervisor/conf.d/myapp.conf
[program:myapp]
autostart = true
autorestart = true
command = python /home/pi/myapp.py
environment=SECRET_ID="secret_id",SECRET_KEY="secret_key_avoiding_%_chars"
stdout_logfile = /home/pi/stdout.log
stderr_logfile = /home/pi/stderr.log
startretries = 3
user = pi
package main
import (
"fmt"
"io"
"os"
)
var path = "/Users/novalagung/Documents/temp/test.txt"
@ambross
ambross / gist:ae9a848d54c3ce01335cbf2de323a591
Created January 31, 2017 09:56 — forked from seanh/gist:555602
Keyboard shortcuts in PyGTK
self._window.connect("key-press-event",self._key_press_event)
def _key_press_event(self,widget,event):
keyval = event.keyval
keyval_name = gtk.gdk.keyval_name(keyval)
state = event.state
ctrl = (state & gtk.gdk.CONTROL_MASK)
if ctrl and keyval_name == 's':
self._notewindow.save()
elif ctrl and keyval_name == 'l':

Frosted Glass Effect: Nightly

An implementation of the iOS 7 Frosted Glass Blur in HTML5 with the Ionic Framework.

A Pen by Ionic on CodePen.

License.

@ambross
ambross / gist:fd8dee958d72d6e4e42b8ed0c994594d
Created August 3, 2016 20:30 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

<!DOCTYPE html>
<html>
<head>
<title>Hello loop</title>
</head>
<body>
<?php
$data = "Hello world I am Awesome";
$img = 'http://lorempixel.com/output/food-q-c-640-480-7.jpg';
@ambross
ambross / parseInt.py
Created June 14, 2016 07:10 — forked from lsauer/parseInt.py
Python: JavaScript like parseInt function in one line
#lsauer.com, 2013
#Note: -)for convenience the function uses the re-module, but can be rewritten to fit into a lambda expression
# -)choose any other, more-expressive return type such as NumPy's `nan` over None if you like
#demonstrative-version:
def parseInt(sin):
import re
return int(''.join([c for c in re.split(r'[,.]',str(sin))[0] if c.isdigit()])) if re.match(r'\d+', str(sin), re.M) and not callable(sin) else None
#via a simple regex:
@ambross
ambross / gist:6b19894ffd69be878ab91838c84adcc5
Created May 29, 2016 18:13 — forked from danpette/gist:a4f9cd207f669f99b882
Ubuntu 14.04 Setup: nginx + varnish + memcached + php5.6 + mysql5.6 + Mongodb 2.6.7 + phpmyadmin
# Basic
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install htop
sudo apt-get install curl
#MySQL
sudo apt-get install mysql-server-5.6 php5-mysql
sudo mysql_install_db
sudo /usr/bin/mysql_secure_installation