Skip to content

Instantly share code, notes, and snippets.

View kassadin's full-sized avatar
:octocat:
新年好

kassadin

:octocat:
新年好
View GitHub Profile
@kassadin
kassadin / generatepublicresources.gradle
Created October 17, 2019 09:35 — forked from HannahMitt/generatepublicresources.gradle
This is a gradle task to generate the public.xml file in an Android library project. It assumes all public resources are kept in a res-public/ resource source directory. Providing this as a starting point, but there may be more efficient ways.
import groovy.xml.MarkupBuilder
// Task to generate our public.xml file
// See https://developer.android.com/studio/projects/android-library.html#PrivateResources
// We assume resources within res-public are public
task generatepublicxml {
def resDir = project.projectDir.absolutePath + "/src/main/res-public"
// Include the desired res types
@kassadin
kassadin / docker-for-mac.md
Created May 4, 2018 19:44 — forked from BretFisher/docker-for-mac.md
Getting a Shell in the Docker for Mac Moby VM

2018 Update: Easiest option is Justin's repo and image

Just run this from your Mac terminal and it'll drop you in a container with full permissions on the Moby VM. This also works for Docker for Windows for getting in Moby Linux VM (doesn't work for Windows Containers).

docker run -it --rm --privileged --pid=host justincormack/nsenter1

more info: https://github.com/justincormack/nsenter1


@kassadin
kassadin / resize_window.scpt
Created April 24, 2018 18:36
osx resize window, but how to run it without the editor?
-- set screenWidth to (do shell script "system_profiler SPDisplaysDataType | awk '/Resolution/{print $2}'")
-- set screenHeight to (do shell script "system_profiler SPDisplaysDataType | awk '/Resolution/{print $4}'")
on run argv
set {width, height, scale} to words of (do shell script "system_profiler SPDisplaysDataType | awk '/Built-In: Yes/{found=1} /Resolution/{width=$2; height=$4} /Retina/{scale=($2 == \"Yes\" ? 2 : 1)} /^ {8}[^ ]+/{if(found) {exit}; scale=1} END{printf \"%d %d %d\\n\", width, height, scale}'")
log width
log height
log scale
@kassadin
kassadin / colors.py
Created May 28, 2017 05:24 — forked from sheljohn/colours-old.py
Print with colors in most shells (Python, standalone)
class ColorPrinter:
"""
Usage:
cprint = ColorPrinter()
cprint.cfg('c','m','bux').out('Hello','World!')
cprint.rst().out('Bye now...')
See: http://stackoverflow.com/a/21786287/472610
See: https://en.wikipedia.org/wiki/ANSI_escape_code
"""
sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
## ubuntu 14.04 清华镜像
#sudo curl -O https://gist.githubusercontent.com/kassadin/bcb1e07863f40f61be5dc5561149856f/raw/8c74bd0d66002940129ce284b816d9af071e6c08/sources.list
sudo wget -P /etc/apt/ https://gist.githubusercontent.com/kassadin/bcb1e07863f40f61be5dc5561149856f/raw/8c74bd0d66002940129ce284b816d9af071e6c08/sources.list
sudo apt-get -y update
sudo apt-get -y install zip unzip git
# sdkman nedd zip unzip
curl -s "https://get.sdkman.io" | bash
@kassadin
kassadin / settings.xml
Created April 18, 2017 15:31
maven settings.xml aliyun
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
@kassadin
kassadin / config
Created April 18, 2017 15:25
sdkman auto answer config
sdkman_auto_answer=true
sdkman_auto_selfupdate=false
sdkman_insecure_ssl=false
sdkman_disable_gvm_alias=false
sdkman_curl_connect_timeout=7
sdkman_curl_max_time=10
sdkman_beta_channel=false
sdkman_debug_mode=false
sdkman_colour_enable=true
@kassadin
kassadin / sources.list
Created April 18, 2017 15:11
ubuntu 14.04 sources.list
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-security main restricted universe multiverse
@kassadin
kassadin / SystemUiHelper.java
Created December 14, 2015 09:41 — forked from chrisbanes/SystemUiHelper.java
SystemUiHelper
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
package org.paulbetts.shroom.core;
import android.os.AsyncTask;
import com.squareup.okhttp.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;