Skip to content

Instantly share code, notes, and snippets.

@liyinsg
liyinsg / gitea-sync.sh
Created December 23, 2020 07:25
Batch sync all gitea repos
#!/bin/bash
GITEA_API=http://sgsxdev005.isng.intel.com:6998/api/v1
GITEA_TOKEN=xxxx24939dc220dc7fc65c04d5ee9f04f5exxxx
page=1
while true; do
JSON=$(curl -X GET "$GITEA_API/repos/search?uid=2&mode=mirror&page=${page}&limit=512&access_token=$GITEA_TOKEN" -H "accept: application/json")
NEWREPO=$(echo $JSON | python2 -c "import sys, json; print ' '.join([str(p['name']) for p in json.load(sys.stdin)['data']])")
[ -z "$NEWREPO" ] && break
REPOS+=" "$NEWREPO
(( page++ ))
@liyinsg
liyinsg / migrate.sh
Created December 23, 2020 07:23
repo to gitea batch migration
#!/bin/bash
# repo forall -c /path/to/migrate.sh
GITEA_REPO=/local/yinli/repos/mirror
GITEA_API=http://sgsxdev005.isng.intel.com:6998/api/v1
GITEA_TOKEN=xxxx24939dc220dc7fc65c04d5ee9f04f5exxxx
REMOTE_URL=https://gts-chd.intel.com/scm
REMOTE_PASS="password"
REMOTE_USER="yinli"
migrate()
@liyinsg
liyinsg / profiles.json
Created April 5, 2020 16:58
Windows Terminal profile
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{2c4de342-38b7-51cf-b940-2309a097f518}",
"profiles":
{
@liyinsg
liyinsg / AndroidManifest.xml
Created June 11, 2016 03:50
Bluetooth Tethering status monitor
<receiver android:name=".BtPanStateReceiver">
<intent-filter>
<action android:name="android.bluetooth.pan.profile.action.CONNECTION_STATE_CHANGED" />
</intent-filter>
</receiver>
<service android:name=".BtPanStateReceiver$BtPanService" android:exported="false"></service>
new-instance v0, Ljava/lang/StringBuilder;
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
const-string v1, "addLinkAddress: "
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v0
static private void enableSoftAP(Context context) {
try {
WifiManager wifiManager;
WifiConfiguration config = null;
wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
Method method = wifiManager.getClass().getMethod("setWifiApEnabled",
WifiConfiguration.class, Boolean.TYPE);
method.invoke(wifiManager, config, true);
} catch (NoSuchMethodException e) {
e.printStackTrace();
@liyinsg
liyinsg / covert_svn_to_git.sh
Created March 11, 2016 04:08
Covert SVN to GIT
#!/bin/sh
branches=$(git branch -r | grep -v "origin/tags" | grep -v "trunk" | sed 's/origin\///')
for branch in $branches; do
git branch $branch refs/remotes/origin/$branch
done
tags=$(git branch -r | grep "origin/tags" | sed 's/origin\/tags\///')
for tag in $tags; do
git tag -a -m "tags from SVN" $tag refs/remotes/origin/tags/$tag
sudo x11vnc -auth /var/lib/lightdm/.Xauthority -display :0
@liyinsg
liyinsg / MM repo into
Last active December 27, 2015 03:55
Init AOSP 6.0 repo
repo init -u https://android.googlesource.com/platform/manifest --reference=/var/aosp -b android-6.0.0_r1
sudo apt-get install ant
mkdir $HOME/webrtc && cd $_
export GYP_DEFINES="OS=android build_with_libjingle=1 build_with_chromium=0 libjingle_java=1 enable_tracing=1"
fetch webrtc_android
cd src
./build/install-build-deps-android.sh
gclient runhooks
. build/android/envsetup.sh
ninja -C out/Debug AppRTCDemo