Skip to content

Instantly share code, notes, and snippets.

View vmptk's full-sized avatar
🐉
Focusing

Venelin vmptk

🐉
Focusing
View GitHub Profile
@vmptk
vmptk / Ratpack.groovy
Last active August 29, 2015 14:23 — forked from rhart/Ratpack.groovy
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import ratpack.handling.Context
import ratpack.handling.Handler
import ratpack.http.client.HttpClient
import ratpack.http.client.StreamedResponse
import ratpack.http.MutableHeaders
import ratpack.http.client.RequestSpec
import static ratpack.groovy.Groovy.ratpack
@vmptk
vmptk / HDD.groovy
Last active August 29, 2015 14:24 — forked from keyle/HDD.groovy
package utils
import groovy.json.JsonBuilder
import groovy.json.JsonSlurper
class HDD {
static save(Object content, String filePath) {
new File(filePath).write(new JsonBuilder(content).toPrettyString())
}
@vmptk
vmptk / migrate-jira-to-github-issues.groovy
Last active August 29, 2015 14:25 — forked from graemerocher/migrate-jira-to-github-issues.groovy
JIRA to Github Issues Migration Script
@Grab(group='com.github.groovy-wslite', module='groovy-wslite', version='1.1.0')
@Grab(group='joda-time', module='joda-time', version='2.7')
import wslite.rest.*
import org.joda.time.*
import org.joda.time.format.*
import groovy.xml.*
import groovy.json.*
import static java.lang.System.*
import groovy.transform.*
@vmptk
vmptk / countries.json
Created January 8, 2016 21:34 — forked from keeguon/countries.json
A list of countries in JSON
[
{name: 'Afghanistan', code: 'AF'},
{name: 'Åland Islands', code: 'AX'},
{name: 'Albania', code: 'AL'},
{name: 'Algeria', code: 'DZ'},
{name: 'American Samoa', code: 'AS'},
{name: 'AndorrA', code: 'AD'},
{name: 'Angola', code: 'AO'},
{name: 'Anguilla', code: 'AI'},
{name: 'Antarctica', code: 'AQ'},
/**
* This script will automatically sync all updates from one database to another. It is meant to be run while
* syncing the database using mongodump and mongorestore.
*
* Example:
* node index.js mongodb://<user>:<pass>@dbhost.com:10645/app-production \
* mongodb://<user>:<pass>@dbhost.com:10499/local?authSource=app-production \
* app-production \
* mongodb://<user>:<pass>@newdbhost.com/app-prod
*/
@PropertySource("classpath:/com/myco/app.properties")
@Configuration
public class ApplicationConfig {
@Autowired
Environment env;
//...
@Bean
@vmptk
vmptk / Jenkinsfile
Created December 16, 2016 14:56 — forked from loverde/Jenkinsfile
Best of Jenkinsfile, a collection of useful workflow scripts ready to be copied into your Jenkinsfile on a per use basis.
#!groovy
# Best of Jenkinsfile
# `Jenkinsfile` is a groovy script DSL for defining CI/CD workflows for Jenkins
node {
}
@vmptk
vmptk / Main.java
Created August 1, 2017 14:40
WebClient with SSL
// Build Netty SslContext
SslContext sslContext = SslContextBuilder
.forClient()
// ...
.build();
// Initialize ReactorClientHttpConnector with SslContext
WebClient.create(new ReactorClientHttpConnector(opts -> opts.sslContext(sslContext)));
@vmptk
vmptk / index.test.js
Created September 11, 2017 21:22 — forked from RStankov/index.test.js
React test trick
// filename: components/CustomComponent/index.test.js
import React from 'react';
// Don't use component actual name, in this way
// when you rename the component, no test change is required
import Component from './index';
describe(Component.name, () => {
// Use SUD (system under test) component for the tests
// in this way each test contains only the props, specific to this test
@vmptk
vmptk / Auth.js
Created March 4, 2019 23:11 — forked from lfades/Auth.js
Next.js Auth implementation: Apollo Server + Passport + Passport-jwt
/**
* server/dataSources/Auth.js
* Auth implementation, it's not really a dataSource so it doesn't need to be here
*/
const { authenticate, createJwt } = require('../lib/passport');
const { ON_HTTPS } = require('../configs');
const ONE_MINUTE = 1000 * 60;
const ONE_DAY = ONE_MINUTE * 60 * 24;
const ONE_MONTH = ONE_DAY * 30;