Skip to content

Instantly share code, notes, and snippets.

@admataz
admataz / random-snippets.md
Last active May 27, 2017 19:09
random snippets
@admataz
admataz / wp_custom_fields_rest_support.php
Last active March 10, 2017 16:56
Adding a support to WP REST API for custom fields
<?php
function my_custom_fields_rest_support( $post ) {
$custom = get_post_meta($post['id']);
$fields = array();
foreach($custom as $key=>$value) {
// Assuming Types - could be other Custom Field Types
if(substr($key, 0, 5) == 'wpcf-'){
$fields[str_replace('wpcf-', '', $key)] = $value;
}
}
@admataz
admataz / package.json
Created November 13, 2016 21:46
package.json for es6 browserify projects
{
"name": "babel",
"version": "1.0.0",
"description": "Website ",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"vendor-js": "mkdirp ./public/js/ && browserify -r VENDOR_DEPENDENCIES | uglifyjs > ./public/js/vendor.js",
"browserify-js": "mkdirp ./public/js/ && browserify --debug -t [babelify --presets [ es2015 ] ] -t brfs -x VENDOR_DEPENDENCIES ./src/index.js --standalone pictoGraphic > ./public/js/pictoGraphic.js",
"process-sass": "mkdirp ./public/css/ && node-sass ./src/sass/main.scss ./public/css/main.css",
@admataz
admataz / keymap.cson
Created October 6, 2016 11:25
my atom keybindings
'.platform-darwin atom-text-editor':
'cmd-alt-down': 'editor:duplicate-lines'
'cmd-d': 'editor:delete-line'
'cmd-shift-w': 'tabs:CloseAllTabs'
'cmd-?': 'sublime-block-comment:toggle'
'cmd-alt-l': 'linter:togglePanel'
'alt-down': 'editor:move-line-down'
'alt-up': 'editor:move-line-up'
'cmd-l': 'go-to-line:toggle'
[xdebug]
xdebug.remote_connect_back=1
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_log="/tmp/xdebug.log"
zend_extension=/usr/lib/php5/20121212/xdebug.so
@admataz
admataz / Vagrantfile
Last active December 18, 2015 22:57
Setting up Vagrant dev server for LAMP
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "private_network", ip: "192.168.33.33"
config.vm.network :forwarded_port, guest: 22, host: 2223, id: 'ssh'
config.vm.provision "shell", path: "./vagrant_setup.sh"
config.vm.synced_folder "./webroot", "/var/www/html", type: "nfs"
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
vb.name = "Virtual Dev Server"
end
@admataz
admataz / gist:02885c976bd601dfa5dc
Last active December 16, 2015 11:53
Notes for 16 December 2015

Some of the more interesting PHP libs emerging

@admataz
admataz / count_group_by.sql
Created August 19, 2015 09:29
select and count group by SQL
select town, count(town)
from user
group by town
@admataz
admataz / gist:fcce6d7f3dffbfd060d5
Last active August 29, 2015 14:27
Drush alias for vagrant server
<?php
$aliases['tpzdev'] = array(
'uri' => '192.168.33.10',
'root' => '/var/www/html',
'remote-host' => '192.168.33.10',
'remote-user' => 'vagrant',
'ssh-options' => '-i /path/to/insecure/vagrantvm/private_key'
);
@admataz
admataz / gist:92bc7f98e7b3042f4399
Created June 19, 2015 21:06
markdown URL bookmarklet
function collectWebItemData() {
var webItem = {};
var linkTitle = (document.title);
var linkLocation = (window.location);
var selectedText = '';
if (window.getSelection) {
selectedText = window.getSelection();
} else if (document.getSelection) {
selectedText = document.getSelection();