Skip to content

Instantly share code, notes, and snippets.

View wenzhixin's full-sized avatar

文翼 wenzhixin

View GitHub Profile
@likema
likema / samsung-smart
Last active August 2, 2023 01:32
Samsung SATA SSD SMART info.
#!/bin/sh
get() {
echo "$SMART_INFO" | awk "/$1/ {print $2}"
}
device_number() {
printf "%u\n" 0x`stat -c $2 $1`
}
@bench
bench / gitlab-merge-request.sh
Last active September 1, 2022 04:20
A script to create gitlab MR from a shell
#!/bin/bash
# Check if jq is installed
if ! type "jq" > /dev/null; then
echo please install jq
fi
title="$(git log --oneline | head -1 | cut -f 2- -d ' ')"
source_branch="$(git branch | grep '*' | cut -f 2 -d ' ')"
target_branch=master
@likema
likema / remove_old_kernels
Last active May 5, 2020 09:12
Remove old Debian/Ubuntu kernel versions.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim: set ts=4 sw=4 sts=4 et:
from distutils.version import LooseVersion
from subprocess import Popen, PIPE
from re import compile as rcomp
from os import uname, system
from sys import exit
from argparse import ArgumentParser, ArgumentTypeError
@DarrenN
DarrenN / get-npm-package-version
Last active April 17, 2024 16:57 — forked from yvele/get-npm-package-version.sh
Extract version from package.json (NPM) using bash / shell
# Version key/value should be on his own line
PACKAGE_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g')
echo $PACKAGE_VERSION
@wenzhixin
wenzhixin / ubuntu14.04-command-line-install-android-sdk
Last active January 16, 2024 21:15
Ubuntu 14.04 command line install android sdk
# install openjdk
sudo apt-get install openjdk-7-jdk
# download android sdk
wget http://dl.google.com/android/android-sdk_r24.2-linux.tgz
tar -xvf android-sdk_r24.2-linux.tgz
cd android-sdk-linux/tools
# install all sdk packages
@wenzhixin
wenzhixin / install-openldap-gosa-ubuntu14.04
Last active July 10, 2020 05:36
Install guide for OpenLDAP and GOsa on Ubuntu 14.04
sudo apt-get install slapd ldap-utils
sudo dpkg-reconfigure slapd
sudo apt-get install gosa gosa-schema
sudo vi /etc/ldap/convert.conf << EOT
include /etc/ldap/schema/core.schema
include /etc/ldap/schema/cosine.schema
include /etc/ldap/schema/nis.schema
include /etc/ldap/schema/inetorgperson.schema
@wenzhixin
wenzhixin / redmine-3.0.2-on-ubuntu-14.04
Last active November 15, 2017 09:30
redmine 3.0.2 installer on ubuntu 14.04(new installtion) with nginx, mysql and puma
# set cache proxy
sudo vi /etc/apt/apt.conf << EOT
Acquire::http::Proxy "http://192.168.88.10:3142";
Acquire::HTTP::Proxy::192.168.88.10 "DIRECT";
EOT
sudo apt-get update
sudo apt-get upgrade
@domenic
domenic / 0-github-actions.md
Last active April 8, 2024 23:35
Auto-deploying built products to gh-pages with Travis

Auto-deploying built products to gh-pages with GitHub Actions

This is a set up for projects which want to check in only their source files, but have their gh-pages branch automatically updated with some compiled output every time they push.

A file below this one contains the steps for doing this with Travis CI. However, these days I recommend GitHub Actions, for the following reasons:

  • It is much easier and requires less steps, because you are already authenticated with GitHub, so you don't need to share secret keys across services like you do when coordinate Travis CI and GitHub.
  • It is free, with no quotas.
  • Anecdotally, builds are much faster with GitHub Actions than with Travis CI, especially in terms of time spent waiting for a builder.
@wenzhixin
wenzhixin / jquery.base64.js
Created October 29, 2014 02:28
Base64 plugin support unicode characters.
jQuery.base64 = (function($) {
// private property
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
// private method for UTF-8 encoding
function utf8Encode(string) {
string = string.replace(/\r\n/g,"\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {
@cmawhorter
cmawhorter / proxy.js
Created June 26, 2014 05:36
Node script to forward all http requests to another server and return the response with an access-control-allow-origin header. Follows redirects.
// Simple proxy/forwarding server for when you don't want to have to add CORS during development.
// Usage: node proxy.js
// Open browser and navigate to http://localhost:9100/[url]
// Example: http://localhost:9100/http://www.google.com
// This is *NOT* for anything outside local development. It has zero error handling among other glaring problems.
// This started as code I grabbed from this SO question: http://stackoverflow.com/a/13472952/670023