Skip to content

Instantly share code, notes, and snippets.

View zhanglianxin's full-sized avatar
🏃‍♂️
Running

Lianxin Zhang zhanglianxin

🏃‍♂️
Running
View GitHub Profile
@dcchambers
dcchambers / md2pdf.md
Last active July 7, 2024 14:16
Generate a PDF from Markdown files with Pandoc

Generate a PDF from a Markdown file with Pandoc

Easy Steps For Mac OS

  1. Have Homebrew installed and a markdown file you want to render to PDF.
  2. Install Pandoc brew install pandoc
  3. Install basictex brew cask install basictex - needed for the pdflatex tool.
  4. Symlink the pdflatex to your /usr/local/bin so pandoc can easily find it. ln -s /Library/TeX/Root/bin/x86_64-darwin/pdflatex /usr/local/bin/pdflatex
  5. Use Pandoc to generate a PDF from a Markdown file. pandoc input.md -o output.pdf
  • By default the margins are pretty large. To optionally change the margins: pandoc input.md -o output.pdf -V geometry:margin=1in
#!/usr/bin/env bash
set -euo pipefail
DOMAIN=$1
SUB_DOMAIN="${2}.${DOMAIN}"
CF_ID=$3
CF_KEY=$4
IP=
#!/usr/bin/env bash
set -euo pipefail
cd `dirname $0`
# lock it
PIDFILE="/tmp/$(basename "${BASH_SOURCE[0]%.*}.pid")"
exec 200>${PIDFILE}
flock -n 200 || ( echo "${BASH_SOURCE[0]} script is already running. Aborting . ." && exit 1 )
PID=$$
#!/usr/bin/env bash
set -euo pipefail
cd `dirname $0`
# lock it
PIDFILE="/tmp/$(basename "${BASH_SOURCE[0]%.*}.pid")"
exec 200>${PIDFILE}
flock -n 200 || ( echo "${BASH_SOURCE[0]} script is already running. Aborting . ." && exit 1 )
PID=$$
@luw2007
luw2007 / logger.go
Created November 17, 2018 06:04
Go logging for human
package log
import (
"bytes"
"path"
"time"
"github.com/gin-gonic/gin"
"github.com/lestrrat/go-file-rotatelogs"
"github.com/pkg/errors"
@Ryanb58
Ryanb58 / install.md
Last active June 25, 2024 19:59
How to install telnet into a alpine docker container. This is useful when using the celery remote debugger in a dev environment.
>>> docker exec -it CONTAINERID /bin/sh
/app # telnet
/bin/sh: telnet: not found

/app # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
v3.7.0-243-gf26e75a186 [http://dl-cdn.alpinelinux.org/alpine/v3.7/main]
v3.7.0-229-g087f28e29d [http://dl-cdn.alpinelinux.org/alpine/v3.7/community]
@troatie
troatie / CreatesWithLock.php
Last active September 12, 2023 13:51
Guard against race conditions in Laravel's firstOrCreate and updateOrCreate
trait CreatesWithLock
{
public static function updateOrCreate(array $attributes, array $values = [])
{
return static::advisoryLock(function () use ($attributes, $values) {
// emulate the code found in Illuminate\Database\Eloquent\Builder
return (new static)->newQuery()->updateOrCreate($attributes, $values);
});
}
@dideler
dideler / bot.rb
Last active July 15, 2024 06:56
Sending a notification message to Telegram using its HTTP API via cURL
# Use this script to test that your Telegram bot works.
#
# Install the dependency
#
# $ gem install telegram_bot
#
# Run the bot
#
# $ ruby bot.rb
#
@zthxxx
zthxxx / Activate Office 2019 for macOS VoL.md
Last active July 15, 2024 13:25
crack activate Office on mac with license file
@hayajo
hayajo / gh_pr_issues.sh
Last active May 7, 2019 17:38
GitHubのPRとISSUEを取ってくる
#!/bin/bash
set -eu
OWNER=${1:?"repo onwer required"}
URL_BASE="https://api.github.com"
REPOS_URL="/users/$OWNER/repos?per_page=100"
PULLS_URL="/repos/$OWNER/%s/pulls"
ISSUES_URL="/repos/$OWNER/%s/issues"