Skip to content

Instantly share code, notes, and snippets.

View macsf's full-sized avatar

Sutthichok Wongthavorn macsf

View GitHub Profile
@macsf
macsf / gist:639c10efebf05da2e23735581bb16575
Created September 20, 2019 04:24
Activate Google Chrome Tab for Specified URL (Keyboard Maestro)
property ptyScriptName : "Activate Google Chrome Tab for Specified URL"
property ptyScriptVer : "1.2" -- ADD Activate Google command
property ptyScriptDate : "2018-10-13"
property ptyScriptAuthor : "estockly" -- adapted for KM by JMichaelTX
(*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PURPOSE:
• Activate Google Chrome Tab for Specified URL
• If URL is for existing Tab, that Window/Tab will be made frontmost
@macsf
macsf / magento-sku-search-get-stock.php
Created February 6, 2018 15:22
Magento : Quickly search for products by SKU (wildcard) and list the stock
<?php
$soap_url = 'http://magento.url/index.php/api/v2_soap?wsdl';
$client = new SoapClient($soap_url);
$session = $client->login('api_user', 'api_key');
$sku = 'msj006c';
$filter = [
'complex_filter' => [
[
@macsf
macsf / atom-runfileinterminal.js
Last active June 7, 2017 05:52
run current file in terminal
'use babel'
import * as helper from './helper'
const { exec } = require('child_process')
const ws = atom.workspace
class RunFileInTerminal {
run = () => {
@macsf
macsf / keybase.md
Last active September 6, 2017 00:10

Keybase proof

I hereby claim:

  • I am macsf on github.
  • I am macsf (https://keybase.io/macsf) on keybase.
  • I have a public key ASBiy0j6U-P_f0R9PwTSt6lXGp353OeExm1P8TTu2slCWgo

To claim this, I am signing this object:

@macsf
macsf / cons_car_cdr.js
Created April 18, 2017 05:07
cons - car - cdr // in es6
const cons = (a, b) => c => c(a, b)
const car = f => f((a, b) => a)
const cdr = f => f((a, b) => b)
const list = cons(1, cons(2, null))
console.log(car(list)) // 1
console.log(car(cdr(list))) // 2
console.log(cdr(cdr(list))) // null
@macsf
macsf / gist:7372722
Last active December 27, 2015 18:49
Stock Check (WIP)
SET @doc_year = 2013;
SET @doc_month_beg = 9;
SET @doc_month_end = 11;
SET group_concat_max_len = 2000;
DELIMITER \\
DROP FUNCTION IF EXISTS prep_doc_stmt\\
CREATE FUNCTION prep_doc_stmt (
doc_year INT,
@macsf
macsf / gist:4554248
Created January 17, 2013 07:03
WP: Clean WP Header
<?php
// remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'start_post_rel_link', 10, 0);
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);
@macsf
macsf / gist:4554244
Created January 17, 2013 07:02
WP: Remove Admin Bar
<?php
// remove admin bar
add_filter('show_admin_bar', '__return_false');
//remove_action('init', 'wp_admin_bar_init');
?>
@macsf
macsf / erastos.rb
Created May 27, 2012 08:02
Implementation of Sieve of Eratosthenes (Euler's Sieve) in Ruby
#!/usr/bin/env ruby -w
# Implementation of Sieve of Erastosthenes (Euler's Sieve) in Ruby
# http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes#Euler.27s_sieve
def prime_sieve(x)
primes = Array.new
primes << 2 # first prime
nums = [*3..x].delete_if {
@macsf
macsf / html5_template.html
Last active October 4, 2015 11:17
HTML: Blank HTML5 Template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="imagetoolbar" content="no">
<meta name="viewport" content="width=device-width, initial-scale=1">