Skip to content

Instantly share code, notes, and snippets.

View joeywang's full-sized avatar

Joey Wang joeywang

  • reallyenglish.com
  • London
View GitHub Profile
@joeywang
joeywang / gist:6989333
Created October 15, 2013 09:59
command to encode the mp3 files into lower rate ones.
find . -name '*.mp3'|sed 's/^\.\///g'|xargs -I {} -L1 ffmpeg -y -i {} -q:a 9 ../new/{}
@joeywang
joeywang / check-audio.sh
Last active November 24, 2022 09:54
bash code to detect mp3 download errors
#!/bin/bash -
server='http://assets-server/project'
files=`find . -name '*.mp3'|sed 's/^\.\///g'`
for file in $files
do
result=`curl -s -S -f -m 10 -w '%{content_type}' -H "Cache-Control:no-cache" $server/$file -o /dev/null`
if [ $? -ne 0 ]
then
@joeywang
joeywang / curl.md
Created March 15, 2018 20:46 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@joeywang
joeywang / rebenv.md
Last active November 24, 2022 09:59 — forked from silviorelli/gist:ad8e1d80bdc0245eb7e7
Install Ruby 1.8.7 on Mac OSX 10.11 El Capitan with rbenv
brew install apple-gcc42 openssl libyaml libffi
xcode-select --install
export CC=/usr/local/bin/gcc-4.2
export CFLAGS='-g -O2'
export RUBY_CONFIGURE_OPTS=--with-openssl-dir=`brew --prefix openssl`
export CONFIGURE_OPTS=--with-openssl-dir=`brew --prefix openssl`
rbenv install 1.8.7-p375
✗ bin/rails s
=> Booting Puma
=> Rails 7.0.4 application starting in development
=> Run `bin/rails server --help` for more startup options
Puma starting in single mode...
* Puma version: 6.0.0 (ruby 3.1.2-p20) ("Sunflower")
*  Min threads: 5
*  Max threads: 5
*  Environment: development
  1. access token
# Use a https link. It's important for the authentication part.
gem "your_gem", git: "https://github.com/<owner>/<repo>.git", branch: "your_branch"

1.1 Setup Token 1.2 put into env as BUNDLE_GITHUB__COM detail

apiVersion: apps/v1
kind: Deployment
metadata:
name: vosk
spec:
selector:
matchLabels:
app: vosk
template:
metadata:
const { IncomingWebhook } = require('@slack/webhook');
const url = process.env.SLACK_WEBHOOK_URL;
const webhook = new IncomingWebhook(url);
// Optionally filter what notification types to forward to Slack.
// If empty, all types will be allowed.
const allowedTypeURLs = [];
// slackNotifier is the main function called by Cloud Functions
  1. Remove deprecated support to set Rails.application.config.action_dispatch.show_exceptions to true and false.

Exception won't be raised in specs

   # Raise exceptions instead of rendering exception templates.
-  config.action_dispatch.show_exceptions = false
+  config.action_dispatch.show_exceptions = :none

Fix sequence in PostgreSQL

CREATE OR REPLACE FUNCTION reset_sequences_to_max(schema varchar default 'public', dry_run bool default true)
RETURNS void AS $$
DECLARE
    r RECORD;
    query TEXT;
BEGIN
    -- Loop through all tables