Skip to content

Instantly share code, notes, and snippets.

@hitme
hitme / Mac OS X: Open in Visual Studio Code
Last active April 14, 2020 07:44 — forked from tonysneed/Mac OS X: Open in Visual Studio Code
Add a command to Finder services in Mac OSX to open a folder in VS Code
- Open Automator
- File -> New -> Quick Actions
- Change "Service Receives" to "files or folders" in "Finder"
- Add a "Run Shell Script" action
- Change "Pass input" to "as arguments"
- Paste the following in the shell script box: open -n -b "com.microsoft.VSCode" --args "$*"
- Save it as something like "Open in Visual Studio Code"
@hitme
hitme / scala-annotations
Created May 10, 2019 04:53
scala-annotations
from https://medium.com/@giposse/scala-reflection-f5bde5fce630:
import javaAnnotations.{ SomethingIzable, VaporElement}
import scala.reflect.runtime.{universe => ru}
import ru._
@SomethingIzable(value = “Teletransport”, level = 35)
case class Annotated (
field1 : Integer,
courtesy to https://foofish.net/https-free-for-lets-encrypt.html
第一步:创建 Let's Encrypt 账号
openssl genrsa 4096 > account.key
第二步:创建域名的CSR(CERTIFICATE SIGNING REQUEST)
#创建普通域名私钥
openssl genrsa 4096 > domain.key
#单个域名
openssl req -new -sha256 -key domain.key -subj "/CN=foofish.net" > domain.csr
@hitme
hitme / module-graph.sh
Created April 11, 2018 01:58 — forked from meeuwer/module-graph.sh
Generate Maven module dependency graph for a project
mvn org.fusesource.mvnplugins:maven-graph-plugin:reactor -Dhide-external=true
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")
@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

@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 / 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 / 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: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.