Skip to content

Instantly share code, notes, and snippets.

View nguyenvanduocit's full-sized avatar
🦁
On codecation

Duoc Nguyen nguyenvanduocit

🦁
On codecation
View GitHub Profile
func (h *Handler) exec(requestBody utils.JsonIn) (*utils.JsonOut, error) {
cmd := exec.Command(h.Command)
cmd.Dir = h.WorkingDir
bRequestBody, err := json.Marshal(requestBody)
if err != nil {
return nil, err
}
cmd.Stdin = strings.NewReader(string(bRequestBody))
var out bytes.Buffer
cmd.Stdout = &out
func (h *Handler) Handle(w http.ResponseWriter, r *http.Request){
cmd := exec.Command(h.Command)
cmd.Dir = h.WorkingDir
cmd.Env = append(h.Env, fmt.Sprintf("FN_REQUEST_URL=%s", r.URL.RequestURI()))
requestContent, err := ioutil.ReadAll(r.Body)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprint(w, err)
return
}
<template>
<div id="app" :class="[$style.app]">
<div :class="$style.header">
<nav :class="$style.nav">
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
</nav>
</div>
<main :class="$style.main">
<router-view/>
@nguyenvanduocit
nguyenvanduocit / pre-commit
Created July 30, 2018 10:27
Check for console.log before commit
#!/bin/sh
# 5:23 PM Friday, October 18, 2013 - Jim Priest
# origin script found here: http://python.dzone.com/articles/tips-using-git-pre-commit-hook
# Modified with console checks and to ignore commented file
echo "Executing post-commit checks..."
FILES_PATTERN='\.(js)(\..+)?$'
FORBIDDEN='console\.[clear|dir|log|info|warn|error]'
<?php
/**
* Template Name: Advanced Search
*/
get_header(); ?>
<?php
$min_price = $_GET['min_price'] ?? '';
$max_price = $_GET['max_price'] ?? '';
?>
<div class="wrap">
<?php
/*
Plugin Name: Hello Custom Field
Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
Description: A brief description of the Plugin.
Version: 1.0
Author: duocnguyen
Author URI: http://URI_Of_The_Plugin_Author
License: A "Slug" license name e.g. GPL2
<ul class="post-meta">
<li><span class="post-meta-key">Price:</span> <?php echo esc_html(get_post_meta(get_the_id(), 'Price', true)) ?></li>
<li><span class="post-meta-key">Image:</span> <?php echo esc_html(get_post_meta(get_the_id(), 'Image', true)) ?></li>
<li><span class="post-meta-key">Type:</span> <?php echo esc_html(get_post_meta(get_the_id(), 'Type', true)) ?></li>
</ul>
<?php
/**
* Config for PHP-CS-Fixer ver2
*/
$rules = [
'@PSR2' => true,
// addtional rules
'array_syntax' => ['syntax' => 'short'],
'no_multiline_whitespace_before_semicolons' => true,
'no_short_echo_tag' => true,
@nguyenvanduocit
nguyenvanduocit / mixins.styl
Created April 7, 2018 09:03
Stylus Mixins
// Rem output with px fallback
font-size($sizeValue = 16)
font-size $sizeValue * 1px
font-size (($sizeValue / 16) * 1)rem
// Center block
center-block()
display block
margin-left auto
margin-right auto