Skip to content

Instantly share code, notes, and snippets.

Working from home

bitsnaps bitsnaps

Working from home
Block or report user

Report or block bitsnaps

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
bitsnaps / wordCounter.groovy
Created Jul 25, 2019
Simple wordCounter with Groovy
View wordCounter.groovy
class Phrase {
String phrase
Map wordCount() {
words.collectEntries { [ (it): occurrences(it) ] }
List getWords() {
bitsnaps / sendemail.ppy
Created Jul 3, 2019
Send an email using sendinblue service api
View sendemail.ppy
from sys import stderr
import requests
# make sure this example works
# curl -s | python -c "import json, sys; print(json.load(sys.stdin)['bpi']['USD']['rate'])"
def send_email():
resp ='', headers={'api-key':'YOUR_API_KEY'},
json={"to":{"":"FULL NAME"}, "from":["","Your Full Name"], "subject":"Your Solution","html":"Welcome to <h1>Solution</h1>"})
if resp: #.status_code==200:
bitsnaps / matrices.groovy
Created Jun 21, 2019
Matrix manipulation with groovy by graxxia library
View matrices.groovy
import graxxia.*
def m = new Matrix([[3,4,5],[6,2,3]])
def m1 = [[1,2,3],[2,6,3],[7,4,2]] as Matrix
def m2 = [[2,6,4],[2,3,5],[7,6,5]] as Matrix
def m3 = [[2,3,4],[8,6,2],[10,4,3]] as Matrix
bitsnaps / TikaMetadataExtractor.groovy
Created Jun 19, 2019 — forked from kaisternad/TikaMetadataExtractor.groovy
A Groovy script that extracts metadata from files using Apache Tika. Works recursively on a file hierarchy and writes all found metadata into a single xml file.
View TikaMetadataExtractor.groovy
* Copyright 2013 Kai Sternad
* 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
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
bitsnaps /
Created Dec 13, 2018
Wordpress CLI tool (wp-cli) script installation automation
#! /bin/bash
# Script tested on MacOS 10.14 with Wordpress 5.0
# Original article at:
# Usage:
# ./ MyNewSite
bitsnaps / simple_random_encryption.groovy
Created Sep 4, 2018
Groovy simple random encryption
View simple_random_encryption.groovy
groovy equivalent of java encryption snippet:
def encrypt(def str){
str.collect{s -> (Math.random()*9+1 as int).with{"${it}${((s.toCharacter() as int^it) as byte[]).encodeHex()}"} }.join('-')
def decrypt(def str){
str.split('-').collect{((it[1..2].decodeHex()[0] as int)^ it[0] as int) as char}.join()
bitsnaps / scrape_chinabestprice.groovy
Created Aug 8, 2018
Simple groovy crawler from
View scrape_chinabestprice.groovy
import org.jsoup.*
import org.jsoup.nodes.*
import groovy.json.*
class Main {
static main(args){
bitsnaps / JarUpdater.groovy
Created Jun 5, 2018
Update Jar file by adding new ones with Groovy
View JarUpdater.groovy
import java.util.jar.*
def outputFile = new File("path/to/mylib/MyLib.jar")
def newFile1 = new File("path/to/new/file/NewClass1.class")
def newFile2 = new File("path/to/new/file/NewClass2.class")
updateJarFile(outputFile, newFile1, newFile2)
def updateJarFile(File jarFile, File... files){
def tmpFile = File.createTempFile('tempJar', '.tmp')
bitsnaps / JarMaker.groovy
Created Jun 3, 2018
Create a Jar file programatically using Groovy
View JarMaker.groovy
import java.util.jar.*
def outputFile = "MyLib.jar"
def distDir = "path/to/content/MyLib"
/*Manifest manifest = new Manifest()
manifest.mainAttributes[Attributes.Name.MANIFEST_VERSION] = "1.0"*/
def jar = new JarOutputStream(new File("${new File(distDir).parent}/${outputFile}").newOutputStream()/*, manifest*/)
new File(distDir).eachFileRecurse {
bitsnaps / HelloAwt.groovy
Created Jun 3, 2018
Simple AWT Gui App using what looks like Builder Pattern with Groovy
View HelloAwt.groovy
import java.awt.*
import java.awt.event.*
new Frame(title:"Hello AWT", size:[300, 200], locationRelativeTo: null, visible: true).with {
def tf = add({ new TextField(text:"", bounds: [50,50,150,20])}() )
def l = add({ new Label(bounds: [50,100,250,20]) }())
def b = new Button(label:"Find IP", bounds: [50,150,60,30])
b.addActionListener({ l.text = "IP of ${tf.text} is ${}" })
You can’t perform that action at this time.