Skip to content

Instantly share code, notes, and snippets.

@ceilfors
ceilfors / settings-xml.py
Created Jul 9, 2014
A simple script to provide multiple profiles for your maven settings at {user.home}/.m2/settings.xml. See description in the python file below for details.
View settings-xml.py
description = """A simple script to provide multiple profiles for your maven settings at {user.home}/.m2/settings.xml.
With the folder structure like below, profile [home] and [work] will be available be used.
{user.home}/.m2/profile
|-home
| |-settings.xml
|-work
| |-settings.xml
"""
import argparse, os, shutil
View child.pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>playground</artifactId>
<groupId>playground</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
View child.pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>playground</artifactId>
<groupId>playground</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
View pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>playground</groupId>
<artifactId>testant</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<build>
@ceilfors
ceilfors / externals.py
Last active Oct 12, 2016
Python script to extract all of the svn:externals in a SVN path recursively.
View externals.py
"""
This script is adapted from http://stackoverflow.com/a/10286163/2464295 but without the
multi threading factor of it.
Usage: `externals.py https://svn-server/repository`
Do note that the script is excluding src and hidden directories that starts with dot. Just modify the file
as it's not parameterized.
If you want this script to run faster, SSH to the SVN server and use file protocol.
Usage: `externals.py file:///svn/repository`
@ceilfors
ceilfors / lambda.spec.js
Created Jul 5, 2018
better-dependency-injection-with-laconia
View lambda.spec.js
const { handler } = require("./lambda");
let twitterService;
beforeEach(() => {
// Creates a mocked twitterService
twitterService = {
getLatestTweets: jest.fn().mockReturnValue(Promise.resolve())
};
});
@ceilfors
ceilfors / event-context.js
Created Jul 5, 2018
better-dependency-injection-with-laconia
View event-context.js
const handler = ({ event, context }) => {};
@ceilfors
ceilfors / env.js
Created Jul 5, 2018
better-dependency-injection-with-laconia
View env.js
const handler = ({ env }) => { console.log(env.MY_ENV_VAR); };
@ceilfors
ceilfors / lambda.js
Last active Sep 10, 2018
better-dependency-injection-with-laconia
View lambda.js
const laconia = require("@laconia/core");
// Creates the dependencies
const instances = async () => {
const password = await getPassword();
return { twitterService: new TwitterService(password) };
};
// Declare the dependency you need by destructuring
const handler = ({ twitterService }) => {
@ceilfors
ceilfors / ssh-copy-id.py
Last active Sep 10, 2021
ssh-copy-id for Windows
View ssh-copy-id.py
"""ssh-copy-id for Windows.
Example usage: python ssh-copy-id.py ceilfors@my-remote-machine
This script is dependent on msysgit by default as it requires scp and ssh.
For convenience you can also try that comes http://bliker.github.io/cmder/.
"""
import argparse, os
from subprocess import call