Skip to content

Instantly share code, notes, and snippets.

import android.util.Base64;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
public class CryptographyHelper {
private static final String ALGORITHM = "AES/ECB/ZeroBytePadding";
public static String encrypt(String plaintext, String key) throws Exception {
@virtualadrian
virtualadrian / GenerateEntityPOJO.groovy
Last active October 24, 2023 08:13
IntelliJ Generators For Entity ( JPA Entity, View Model, Rest Controller ) - WIP plz comment with desires -
import com.intellij.database.model.DasTable
import com.intellij.database.model.ObjectKind
import com.intellij.database.util.Case
import com.intellij.database.util.DasUtil
/*
* Available context bindings:
* SELECTION Iterable<DasObject>
* PROJECT project
* FILES files helper
@existme
existme / Generate Markdown.groovy
Created September 29, 2017 13:14
This script will copy the selected table schemas as markdown tables into the clipboard. #IntelliJ #db #database #extractors #schema
import com.intellij.database.model.DasTable
import com.intellij.database.model.ObjectKind
import com.intellij.database.util.Case
import com.intellij.database.util.DasUtil
SEPARATOR = ","
QUOTE = "\""
NEWLINE = System.getProperty("line.separator")
SEPARATOR = File.separator
SPACING = " "
@cdesch
cdesch / rails_generator_cheat_sheet.md
Last active May 20, 2025 22:33
Rails Generator CheatSheet

Cheat Sheets are greate but they are not a substitute for learning the framework and reading the documentation as we most certainly have not covered every potential example here. Please refer to the Rails Command Line Docs for more information.

Command Line Generator Info

Reference

You can get all of this information on the command line.

rails generate with no generator name will output a list of all available generators and some information about global options. rails generate GENERATOR --help will list the options that can be passed to the specified generator.

@jgrodziski
jgrodziski / settings.xml
Created September 10, 2017 16:00
maven settings.xml including clojars repo
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository/>
<interactiveMode/>
<usePluginRegistry/>
<offline/>
<pluginGroups/>
<servers/>
@ibalashov
ibalashov / scratch_121.txt
Created August 28, 2017 07:57
List vs HashSet performance for small lists (single contains op)
public static List<Integer> generate(int series) {
return Stream.iterate(new int[]{0, 1}, s -> new int[]{s[1], s[0] + s[1]})
.limit(series)
.map(n -> n[0])
.collect(Collectors.toList());
}
public static void main(String[] args) {
generate(30).forEach(n -> {
List<String> collected = Stream.generate(() -> UUID.randomUUID().toString()).limit(n).collect(Collectors.toList());
import com.google.common.base.CaseFormat
import com.intellij.database.model.DasObject
import com.intellij.database.model.DasTable
import com.intellij.database.model.ObjectKind
import com.intellij.database.util.Case
import com.intellij.database.util.DasUtil
/**
* modification of origin script :
* - add comment support (if you are non native English user, it is very important)
keywords = {
["date"] = function() return os.date("%B %d, %Y") end,
["name"] = "my name is MISTER",
}
expander = hs.hotkey.bind({"alt"}, "d", nil, function() -- don't start watching until the keyUp -- don't want to capture an "extra" key at the begining
local what = ""
local keyMap = require"hs.keycodes".map -- shorthand... in a formal implementation, I'd do the same for all `hs.XXX` references, but that's me
local keyWatcher
keyWatcher = hs.eventtap.new({ hs.eventtap.event.types.keyUp, hs.eventtap.event.types.keyDown }, function(ev)
@jrongbin
jrongbin / init.lua
Created June 18, 2017 12:09
中英文切换
hs.hotkey.bind({"cmd", "alt", "ctrl", "shift"}, "Z", function()
if hs.keycodes.currentSourceID() == "com.apple.keylayout.US" then
hs.eventtap.keyStroke({}, "f19")
end
end)
hs.hotkey.bind({"cmd", "alt", "ctrl", "shift"}, "E", function()
if hs.keycodes.currentSourceID() ~= "com.apple.keylayout.US" then
hs.eventtap.keyStroke({}, "f19")
end
@ericksli
ericksli / TimberJava.xml
Last active February 11, 2021 18:19
Timber Android Studio live template for Java and Kotlin #kotlin #android
<templateSet group="TimberJava">
<template name="timd" value="timber.log.Timber.d(&quot;$METHOD_NAME$: $content$&quot;);" description="Timber.d(String)" toReformat="true" toShortenFQNames="true">
<variable name="METHOD_NAME" expression="methodName()" defaultValue="" alwaysStopAt="false" />
<variable name="content" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
<template name="time" value="timber.log.Timber.e($exception$, &quot;$METHOD_NAME$: $content$&quot;);" description="Timber.e(Exception, String)" toReformat="true" toShortenFQNames="true">
<variable name="exception" expression="" defaultValue="e" alwaysStopAt="true" />