Skip to content

Instantly share code, notes, and snippets.

@i-sync
i-sync / String Format With Name
Created September 30, 2016 09:52
String Format With Name
public static string FormatWith(this string format, object source)
{
return FormatWith(format, null, source);
}
public static string FormatWith(this string format, IFormatProvider provider, object source)
{
if (format == null)
throw new ArgumentNullException("format");
@i-sync
i-sync / lucene search.cs
Created December 19, 2016 07:36
Lucene .Net
public class HotelSearch
{
public static String IndexFolder => Sitecore.Configuration.Settings.DataFolder.EndsWith("\\")
? Sitecore.Configuration.Settings.DataFolder + "indexes\\hotel_index"
: Sitecore.Configuration.Settings.DataFolder + "\\indexes\\hotel_index";
public void BuildIndex(HotelProperty[] datas)
{
var dataFolder = IndexFolder;
if (!Directory.Exists(dataFolder))
@i-sync
i-sync / v2ex_sign.py
Last active November 13, 2018 10:37
V2EX Login
#!/usr/bin/env python3
#-*- coding=utf-8 -*-
import logging
import requests
import requests.utils
import sys
import re
import os.path
import json
@i-sync
i-sync / ssh-failed.sh
Created February 22, 2017 06:12
SSH-Failed
#!/bin/sh
SCANIP=`grep "Failed" /var/log/secure | awk '{print $(NF-3)}' | sort | uniq -c | awk '{print $1"="$2;}'`
for i in $SCANIP
do
NUMBER=`echo $i | awk -F= '{print $1}'`
SCANIP=`echo $i | awk -F= '{print $2}'`
echo "$SCANIP:$NUMBER"
if [ $NUMBER -gt 10 ]
then
grep $SCANIP /etc/hosts.deny >/dev/null 2>&1 || echo "sshd:$SCANIP" >> /etc/hosts.deny
@i-sync
i-sync / douban.sh
Created August 10, 2017 04:20
use mpc random play douban ten songs
#!/usr/bin/env bash
type='n'
pt='3.1'
channel=1
pb='320'
from='mainsite'
kbps='320'
app_name='radio_website'
client='s:mainsite|y:3.0'
@i-sync
i-sync / v-check.sh
Created August 10, 2017 04:30
play telegram bot voice
#!/bin/bash
#this file is check "voice.sh" script whether is running
#if "voice.sh" script is running , nothing to do
#else run "voice.sh" script
result=`ps aux | grep -i "voice.sh" | grep -v "grep" | wc -l`
echo $result
if [ $result -ge 1 ]
then
echo "voice.sh is running..."
@i-sync
i-sync / volume.sh
Created August 10, 2017 04:43
change raspberry pi volume follow the time one day
num=$(date "+%H")
t=$(date "+%F %T")
echo $num
if [ $num -le 5 ];then
amixer set PCM,0 80%
echo "$t ---> 60" >> /tmp/1.log
elif [ $num -gt 5 ]&&[ $num -lt 9 ];then
amixer set PCM,0 86%
echo "$t ---> 70" >> /tmp/1.log
elif [ $num -ge 9 ]&&[ $num -lt 13 ];then
@i-sync
i-sync / auto.sh
Created August 10, 2017 05:22
frpc auto start script
#!/bin/sh
LOGTIME=$(date "+%F %T")
PRO_NAME=frpc
NUM=$(ps | grep $PRO_NAME | grep -v grep |wc -l)
#echo $NUM >> /tmp/frp.log
if [ "${NUM}" -lt "1" ];then
echo $LOGTIME $PRO_NAME is stop, restarting.... >> /tmp/frp.log
/home/pi/frp/frpc -c /home/pi/frp/frpc.ini -L /home/pi/frp/frpc.log &
@i-sync
i-sync / timeaudio.sh
Created August 10, 2017 05:27
half and hour play corresponding time voice file
#!/bin/bash
filePath=/home/pi/timeaudio
#time=`date | awk -F \ {'print $4'} | awk -F : {'print $1'}`
time=`date +%H%M`
audioFile="$filePath/$time.mp3"
echo $audioFile
player=/usr/bin/mplayer
$player $audioFile
@i-sync
i-sync / cmder-msys2.sh
Created October 14, 2017 16:07
cmder & msys2
%ConEmuDrive%\msys64\usr\bin\bash.exe --login -i -new_console:C:"%ConEmuDrive%\msys64\msys2.ico"