Skip to content

Instantly share code, notes, and snippets.

View xinthink's full-sized avatar

Yingxin Wu xinthink

View GitHub Profile
@xinthink
xinthink / ext-access.build.kts
Created November 15, 2017 01:17
Accessing extra properties in Kotlin DSL
// Declarations
ext["deps"] = mapOf(
"support" to mapOf(
"appCompat" to "com.android.support:appcompat-v7:26.0.2",
"design" to "com.android.support:design:26.0.2"
),
"picasso" to "com.squareup.picasso:picasso:2.5.2"
)
// References
@xinthink
xinthink / dep-models.kt
Created November 15, 2017 01:23
Dependency modeling
interface DependencyItem
data class DependencyNotation(val notation: String) : DependencyItem
class DependencyGroup : DependencyItem {
val dependencies: Map<String, DependencyItem>
}
@xinthink
xinthink / dep-operators.kt
Created November 15, 2017 01:26
Dependency group operators definition
class DependencyGroup {
// provides the `.``[]` operators
operator fun get(key: String): DependencyItem
// provides the `<key>(<notation>)` syntax
operator fun String.invoke(notation: String)
// provides the `<key> {<group>}` syntax
operator fun String.invoke(init: DependencyGroup.() -> Unit)
}
@xinthink
xinthink / deps-ext.kt
Created November 15, 2017 01:42
Hook dependencies extension to ExtraProperties
val ExtraPropertiesExtension.deps: DependencyGroup
get() =
if (has("deps")) this["deps"] as DependencyGroup
else DependencyGroup().apply {
this@deps["deps"] = this
}
@xinthink
xinthink / gradle-dependencies-github.gradle
Created April 4, 2012 10:30
gradle dependencies resolving against GitHub download url
repositories {
add(new org.apache.ivy.plugins.resolver.URLResolver()) {
name = 'GitHub'
addArtifactPattern 'http://cloud.github.com/downloads/[organisation]/[module]/[module]-[revision].[ext]'
}
}
dependencies {
classpath '<githubId>:<artifact>:<revision>'
}
@xinthink
xinthink / ekill
Created April 2, 2013 08:17
Kill process by match the whole command line (like ps -ef) Usage: ekill <pattern> [signal]
#!/bin/bash
SIG="-2"
if [[ "$2" != "" ]]; then
SIG="$2"
fi
ps -ef | grep $1 | grep -v grep | awk '{print $2}' | xargs kill $SIG
@xinthink
xinthink / main.ts
Last active November 6, 2019 13:47
medium-custom-github-actions main.ts
import * as core from '@actions/core';
import { context } from '@actions/github';
import * as request from 'request-promise-native';
(async function run() {
try {
const botToken = core.getInput('botToken');
const chatId = core.getInput('chatId');
const jobStatus = core.getInput('jobStatus');
const skipSuccess = (core.getInput('skipSuccess') || 'true') === 'true';
@xinthink
xinthink / action.yml
Last active November 7, 2019 03:03
medium-custom-github-actions action.yml
name: 'Telegram Action'
description: 'Telegram notification for workflow set up with GitHub Actions'
author: <name>
inputs:
botToken:
description: 'The Telegram Bot token'
required: true
chatId:
description: 'The target to which the message will be sent, can be a Telegram Channel or Group'
required: true
@xinthink
xinthink / package.json
Last active November 7, 2019 03:52
medium-custom-github-actions package.json
{
"scripts": {
"build": "tsc",
"clean": "rm -rf lib package-lock.json",
"rebuild": "yarn clean && yarn build",
"release": "yarn clean && yarn && yarn build && yarn npm-lock && mv -f package-lock.json npm.lock && rm -rf node_modules && yarn --prod && mv npm.lock package-lock.json",
"dev": "yarn clean && yarn",
"npm-lock": "synp -f -s yarn.lock"
}
}
@xinthink
xinthink / phases.csv
Last active November 7, 2019 04:54
medium-custom-github-actions
Branch/Tag Desc Development Distribution
master where we commit changes
releases/v{version} release candidates e.g. releases/v1.0
v{version} tags referred from workflows e.g. v1.0