Skip to content

Instantly share code, notes, and snippets.

View ediamin's full-sized avatar
:octocat:
Exploring

Edi Amin ediamin

:octocat:
Exploring
View GitHub Profile
@ediamin
ediamin / keymap.cson
Created September 16, 2016 17:47
Atom - Custom Keymap
# Your keymap
#
# Atom keymaps work similarly to style sheets. Just as style sheets use
# selectors to apply styles to elements, Atom keymaps use selectors to associate
# keystrokes with events in specific contexts. Unlike style sheets however,
# each selector can only be declared once.
#
# You can create a new keybinding in this file by typing "key" and then hitting
# tab.
#
@ediamin
ediamin / colormeter.js
Created September 30, 2016 12:08 — forked from mailtruck/colormeter.js
Calculate difference in percentage between 2 hex colors
function color_meter(cwith, ccolor) {
if (!cwith && !ccolor) return;
var _cwith = (cwith.charAt(0)=="#") ? cwith.substring(1,7) : cwith;
var _ccolor = (ccolor.charAt(0)=="#") ? ccolor.substring(1,7) : ccolor;
var _r = parseInt(_cwith.substring(0,2), 16);
var _g = parseInt(_cwith.substring(2,4), 16);
var _b = parseInt(_cwith.substring(4,6), 16);
@ediamin
ediamin / wordpress-colorized-button.less
Last active November 7, 2016 05:39
WordPress Colorized Button
.button-colorized(@baseColor) {
background: @baseColor;
border-color: darken(@baseColor, 5%) darken(@baseColor, 9%) darken(@baseColor, 9%);
-webkit-box-shadow: 0 1px 0 darken(@baseColor, 9%);
box-shadow: 0 1px 0 darken(@baseColor, 9%);
color: #fff;
text-decoration: none;
text-shadow: 0 -1px 1px darken(@baseColor, 9%), 1px 0 1px darken(@baseColor, 9%), 0 1px 1px darken(@baseColor, 9%), -1px 0 1px darken(@baseColor, 9%);
&.hover,
@ediamin
ediamin / timezone.js
Created December 7, 2016 08:53
WordPress - Moment Timezone times
// required moment-timezone-with-data.js
String.prototype.toLocalTime = function() {
return moment(moment.tz(this, 'YYYY-MM-DD HH:mm:ss', wpTimezone))
.tz(moment.tz.guess())
.format('YYYY-MM-DD HH:mm:ss');
};
String.prototype.toWPTime = function() {
return moment(this, 'YYYY-MM-DD HH:mm:ss').tz(wpTimezone).format('YYYY-MM-DD HH:mm:ss');
};
@ediamin
ediamin / hooks.php
Created January 21, 2017 04:49
Hooks for saving WP ERP - CRM `photo_id` meta
<?php
/**
* $people_id = contact or company id
* meta data saved in 'PREFIX_erp_peoplemeta' table
* for hook documentation see `update_metadata` function located in `wp-includes/meta.php` WordPress core file
*/
add_filter( 'update_erp_people_metadata', function ( $check, $people_id, $meta_key, $meta_value, $prev_value ) {
if ( 'photo_id' === $meta_key ) {
@ediamin
ediamin / wpautop.js
Created February 27, 2017 09:49
JavaScript version of WordPress wpautop function
// source: https://github.com/andymantell/node-wpautop
function _autop_newline_preservation_helper (matches) {
return matches[0].replace( "\n", "<WPPreserveNewline />" );
},
function wpautop(pee, br) {
if(typeof(br) === 'undefined') {
br = true;
}
@ediamin
ediamin / erp-extra-country-states.php
Last active March 5, 2017 08:41
How to add more country states in WP ERP
<?php
// use `erp_states` filter hook to add country states
add_filter( 'erp_states', function ( $states ) {
$states['NL'] = [
'DR' => 'Drenthe',
'FL' => 'Flevoland',
'FR' => 'Fryslân (fy)',
'GE' => 'Gelderland',
'GR' => 'Groningen',
@ediamin
ediamin / gist:4e7c92c605690fc9ca56157f625c66d6
Created September 4, 2017 12:06 — forked from thomasgriffin/gist:4410690
JS used to customize the new media workflow for Soliloquy.
// Use the new media manager to handle uploads to Soliloquy.
$('#soliloquy-area').on('click.soliloquyUpload', '#soliloquy-upload', function(e){
// Prevent the default action from occuring.
e.preventDefault();
// Variable to hold our media applicaton.
var soliloquy_frame;
// If the media frame already exists, reopen it and return.
if ( soliloquy_frame ) {
@ediamin
ediamin / install_lamp_16.sh
Created December 18, 2017 06:55 — forked from ankurk91/install_lamp_ubuntu.sh
Ubuntu 16.04 - PHP development (php 7.1, MySQL 5.7, apache 2.4)
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# Ubuntu 16.04 Dev Server
# Run like - bash install_lamp.sh
# Script should auto terminate on errors
echo -e "\e[96m Adding PPA \e[39m"
sudo add-apt-repository -y ppa:ondrej/apache2
@ediamin
ediamin / vue-computed-prop.js
Created March 16, 2018 14:58
Example of vue computed property
data() {
return {
questions: [
{
...
},
{
...
}
...