Skip to content

Instantly share code, notes, and snippets.

@hitme
hitme / brew switch
Created August 11, 2014 18:27
brew switch between maven2 and maven30
brew tap homebrew/versoins
brew install FORMULA # here is maven30\maven31\maven2 etc...
brew unlink maven2 # suppose that maven2 (version 2.2.1) is installed previously
brew link maven30 # now maven30 (version 3.0.x) will substitute maven2
# to revert this process, no need to reinstall maven2. just
brew unlink maven30
brew link maven2
@hitme
hitme / howtorunspringshell
Last active August 29, 2015 14:05
how to debug a spring shell project
1. TO run a spring shell project in IDEA
[edit configurations]->add Application->specify [Main class] as "org.springframework.shell.Bootstrap"
2. TO run a spring shell project with maven (exec-maven-plugin)
$ cd path/to/projectRoot (where pom.xml exists)
$ mvn exec:java -Dexec.mainClass="org.springframework.shell.Bootstrap"
reference:
http://docs.spring.io/spring-shell/docs/current/reference/htmlsingle/#d4e260
@hitme
hitme / create_dmg.sh
Last active August 29, 2015 14:12 — forked from dataich/create_dmg.sh
set -ex
[ "$ACTION" = build ] || exit 0
[ "$BUILD_VARIANTS" = "normal" ] || exit 0
[ "$CONFIGURATION" = "Release" ] || exit 0
dir="$TEMP_FILES_DIR/disk"
dmg="$HOME/Desktop/$PROJECT_NAME.dmg"
rm -rf "$dir"
@hitme
hitme / gist:a27687ebcc4ddfe7d92a
Created August 5, 2015 06:39
mac+as+gradle+genymotion搭建android调试环境
1. Download the latest AndroidStudios(AS)
2. Install Genymotion simultor.
3. Download 'gradle-2.2.1-all.zip',and unzip into 'GRADLE_PATH=gradle-2.2.1-all'
4. In AS, search 'Global Gradle settings. Unselect 'offline work',
select 'use local gradle distribution', and specify 'Gradle home' to the GRADLE_PATH directory.
5. Download 'android-sdk_r24.3.3-macosx.zip' and unzip into 'ANDROID_SDK_PATH=android-sdk-macosx'
6. In AS, search 'Android SDK',and specify 'Android SDK Location' to the ANDROID_SDK_PATH directory.
references:
@hitme
hitme / gist:b6006c96b232b0574fa132509de07928
Created August 14, 2016 03:26 — forked from dodyg/gist:5823184
Kotlin Programming Language Cheat Sheet Part 1

#Intro

Kotlin is a new programming language for the JVM. It produces Java bytecode, supports Android and generates JavaScript. The latest version of the language is Kotlin M5.3

Kotlin project website is at kotlin.jetbrains.org.

All the codes here can be copied and run on Kotlin online editor.

Let's get started.

@hitme
hitme / admin.py
Created August 22, 2016 01:56 — forked from rchrd2/admin.py
Adding custom views to django's admin
from django.contrib import admin
from polls.models import Poll, Choice
from django.contrib.auth.models import User
from django.contrib.admin import AdminSite
from polls.views import index
class MyAdminSite(AdminSite):
@hitme
hitme / gist:82f547e704bbd552fdbba35757f7423d
Created November 14, 2016 02:39 — forked from pindia/gist:9b7787a607a5a676c6d8
Django session cookie migration
# Read more at http://www.pindi.us/blog/migrating-cross-domain-cookies-django
from django.conf import settings
from importlib import import_module
class UpdateSessionCookieMiddleware(object):
"""
Migrates session data from an old (hardcoded) session cookie name and domain to the name and
domain currently defined in the Django settings.
@hitme
hitme / dependency-report.gradle
Last active January 25, 2018 03:14 — forked from abesto/dependency-report.gradle
Gradle: multi-project dependency graph
task dependencyReport {
doLast {
def file = new File("project-dependencies.dot")
file.delete()
file << "digraph {\n"
file << "splines=ortho\n"
allprojects.each { item ->
def from = item
from.configurations.compile.dependencies
.matching { it in ProjectDependency }
@hitme
hitme / docker-cleanup-resources.md
Created February 7, 2018 03:14 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

import pygame
pygame.init()
text = "庞中华"
font = pygame.font.Font("/path/to/庞中华行书.ttf", 25)
rtext = font.render(text, True, (0, 0, 0), (255, 255, 255))
pygame.image.save(rtext, "t.gif")