Skip to content

Instantly share code, notes, and snippets.

View smartree's full-sized avatar

JasonSmartree smartree

View GitHub Profile
@smartree
smartree / alternatives-pgsql
Created July 8, 2021 15:57 — forked from snaga/alternatives-pgsql
Switch postgresql version for all the commands with using alternatives.
#!/bin/sh
# alternatives-pgsql
#
# Switch postgresql version for all the commands with using alternatives.
#
# Copyright(C) 2012 Uptime Technologies, LLC. All rights reserved.
PATH=/usr/sbin:$PATH
export PATH
@smartree
smartree / stay-awake.ps1
Created February 14, 2020 07:43 — forked from CMCDragonkai/stay-awake.ps1
Keep Windows Awake Temporarily (Prevent Sleep, Display Off or Away Mode) #cli #powershell #windows
#!/usr/bin/env powershell
# This script can keep the computer awake while executing another executable, or
# if no executable was passed in, then it stays awake until this script stops.
# There are 3 different ways of staying awake:
# Away Mode - Enable away mode (https://blogs.msdn.microsoft.com/david_fleischman/2005/10/21/what-does-away-mode-do-anyway/)
# Display Mode - Keep the display on and don't go to sleep or hibernation
# System Mode - Don't go to sleep or hibernation
# The default mode is the System Mode.
# Away mode is only available when away mode is enabled in the advanced power options.
@smartree
smartree / socket_portable
Created January 6, 2020 09:08 — forked from FedericoPonzi/socket_portable.c
C sockets portable in windows/linux example
// As seen on http://www.di.uniba.it/~reti/LabProRete/Interazione(TCP)Client-Server_Portabile.pdf
#if defined WIN32
#include <winsock.h>
#else
#define closesocket close
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#endif
#include <stdio.h>
@smartree
smartree / gitBash_windows.md
Created January 6, 2020 07:36 — forked from evanwill/gitBash_windows.md
how to add more utilities to git bash for windows, wget, make

How to add more to Git Bash on Windows

Git for Windows comes bundled with the "Git Bash" terminal which is incredibly handy for unix-like commands on a windows machine. It is missing a few standard linux utilities, but it is easy to add ones that have a windows binary available.

The basic idea is that C:\Program Files\Git\mingw64\ is your / directory according to Git Bash (note: depending on how you installed it, the directory might be different. from the start menu, right click on the Git Bash icon and open file location. It might be something like C:\Users\name\AppData\Local\Programs\Git, the mingw64 in this directory is your root. Find it by using pwd -W). If you go to that directory, you will find the typical linux root folder structure (bin, etc, lib and so on).

If you are missing a utility, such as wget, track down a binary for windows and copy the files to the corresponding directories. Sometimes the windows binary have funny prefixes, so

@smartree
smartree / git乱码解决方案汇总.txt
Created December 17, 2019 11:35 — forked from xkyii/git乱码解决方案汇总.txt
git乱码解决方案汇总
原帖地址: http://topic.csdn.net/u/20110113/19/b0d5d506-4307-428b-a61d-7974aa66a2da.html
首先要说明的是:这里介绍的方法都是大部分是本人“悟”出来的,所以网上难有流传!
好方法不能自己私藏,否则就白忙乎这几天了,分享给有需要的朋友们。如果有转载,敬请注明来自*CSDN老邓*作品。
呵呵,给自己打广告,实在是无耻之极,权当无聊之时打字之用。
欢迎流传,为最优秀的分布式版本管理系统Git做宣传!!
步骤:
1. 下载:http://loaden.googlecode.com/files/gitconfig.7z
2. 解压到:<MsysGit安装目录>/cmd/,例如:D:\Program Files\Git\cmd
@smartree
smartree / loop_string.pl
Created December 16, 2019 06:15 — forked from ishu3101/loop_string.pl
3 ways to loop through each character in a string in Perl
# 3 ways to loop through each character in a string
$text = "hello world";
for $i (0..length($text)-1){
$char = substr($text, $i, 1);
print "Index: $i, Text: $char \n";
}
foreach $char (split //, $text) {
@smartree
smartree / install-gcc48-linuxbrew-centos6.md
Created November 21, 2019 06:17 — forked from stephenturner/install-gcc48-linuxbrew-centos6.md
Installing gcc 4.8 and Linuxbrew on CentOS 6

Installing gcc 4.8 and Linuxbrew on CentOS 6

The GCC distributed with CentOS 6 is 4.4.7, which is pretty outdated. I'd like to use gcc 4.8+. Also, when trying to install Linuxbrew you run into a dependency loop where Homebrew's gcc depends on zlib, which depends on gcc. Here's how I solved the problem.

Note: Requires sudo privileges.

Resources:

@smartree
smartree / getDownloadInfo.php
Created November 18, 2019 11:57 — forked from AlanDecode/getDownloadInfo.php
从 GitHub API 获取仓库附件下载量。受 API 限制,下载量统计不包括 Source ​code。
<?php
/**
* GitHub Release 下载监控
*
* @author AlanDecode | 熊猫小A
* @link https://www.imalan.cn
* @version 1.0
*/
$UserName = 'AlanDecode';
@smartree
smartree / download-java8.sh
Created November 13, 2019 04:26 — forked from hgomez/download-java8.sh
wget to download Java 8
wget --continue --no-check-certificate -O jdk-8-linux-x64.tar.gz --header Cookie: oraclelicense=a http://download.oracle.com/otn-pub/java/jdk/8-b132/jdk-8-linux-x64.tar.gz
@smartree
smartree / ps.sh
Created November 11, 2019 07:13 — forked from bingoohuang/ps.sh
ps output lstart in ISO format like YYYY-MM-DD HH:MM:SS
# from: https://unix.stackexchange.com/questions/401785/ps-output-with-iso-date-format
ps -eo lstart,pid,cmd --sort=start_time|sed '1d' | awk '{c="date -d\""$1 FS $2 FS $3 FS $4 FS $5"\" +\047%Y-%m-%dT%H:%M:%S\047"; c|getline d; close(c); $1=$2=$3=$4=$5=""; printf "%s\n",d$0 }'
#2018-04-23T15:38:18 1 /sbin/init
#2018-04-23T15:38:18 2 [kthreadd]
#2018-04-23T15:38:18 3 [migration/0]
#2018-04-23T15:38:18 4 [ksoftirqd/0]
#2018-04-23T15:38:18 5 [stopper/0]
#2018-04-23T15:38:18 6 [watchdog/0]