Skip to content

Instantly share code, notes, and snippets.

@mosheeshel
mosheeshel / gist:6007484
Last active December 19, 2015 19:38 — forked from MichelleGlauser/gist:5323089
getsatisfaction customization code how to add a button to subscribe to a feed (not real product feed)
<!-- Subscribe to all topics. -->
<!-- Steps to a subscribe-to-all-topics button:
1. make a product for all topics, get ID number (87939: http://michelleglauser.jarg0n.com/gsfnmichelle/products/gsfnmichelle_all_topics)
2. make all new topics automatically be assigned to that product by ID number (through a jQuery click on that element)
3. hide that product by ID number
4. make a subscribe button on the front page
5. give the subscribe button a call to the product page's follow button -->
<!-- Header HTML: -->
@mosheeshel
mosheeshel / uri.js
Created July 17, 2013 12:59 — forked from jlong/uri.js
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@mosheeshel
mosheeshel / gist:6020354
Created July 17, 2013 13:00
parseUri 1.2: Split URLs in JavaScript from: http://blog.stevenlevithan.com/archives/parseuri Highlights: Comprehensively splits URIs, including splitting the query string into key/value pairs. (Enhanced) Two parsing modes: loose and strict. (New) Easy to use (returns an object, so you can do, e.g., parseUri(uri).anchor). Offers convenient, pre-…
// parseUri 1.2.2
// (c) Steven Levithan <stevenlevithan.com>
// MIT License
function parseUri (str) {
var o = parseUri.options,
m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
uri = {},
i = 14;
@mosheeshel
mosheeshel / gist:6051907
Created July 22, 2013 07:23
Youtube parsing functions, this are brute force methods to get youtube video ID from URL.
function get_youtube_id( $youtube_url ) {
$url = parse_url($youtube_url);
if( $url['host'] !== 'youtube.com' &&
$url['host'] !== 'www.youtube.com'&&
$url['host'] !== 'youtu.be'&&
$url['host'] !== 'www.youtu.be')
return '';
@mosheeshel
mosheeshel / gist:6078123
Created July 25, 2013 09:17
Android Code for start emulator parameters to "force" hebrew And code to force App to load the hebrew resources (based on language string
// parameters for emulator
-prop persist.sys.language=iw -prop persist.sys.country=IL
// Force Locale Change
String languageToLoad = "iw";
Locale locale = new Locale(languageToLoad);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
@mosheeshel
mosheeshel / ResourceFileResolver.java
Created January 1, 2014 05:28
Locates a file inside your resources whether they are in a "normal" resource directory or inside a jar - untested, for reference only
package com.acme.example;
import com.sun.javaws.Launcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
@mosheeshel
mosheeshel / gist:8279903
Last active January 2, 2016 08:59
Get App version from package manifest (for fatJar)
protected Integer getBuildNumber() {
try {
final String version = App.class.getPackage().getImplementationVersion();
if (StringUtils.isNotEmpty(version)) {
try {
return Integer.parseInt(version.substring(version.lastIndexOf(".") + 1));
} catch (Exception exp) {
logger.error("Problem parsing buildnumber from package version, returning 0", exp);
}
}
@mosheeshel
mosheeshel / Dockerrun.aws.json
Last active January 1, 2017 10:08
Simplified example of AWS multi-container docker definition for Elastic Beanstalk, including authenticating to external non public docker registry to pull images
{
"AWSEBDockerrunVersion": 2, /* newer multi container format */
"authentication": {
/* if working with non ECR or non public docker registries, this is required, points to file in S3,
that has the correct auth data, this could hold auth for multiple registries,
see here: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker.container.console.html#docker-images-private
*/
"bucket": "s3-bucket-name",
"key": "prefix"
},
@mosheeshel
mosheeshel / build.gradle
Created January 23, 2017 18:15
test task that prints out environment variables and those set for JVM executors that gradle will run and shows how to set specific systemProperty from external value...
apply plugin: 'java' //needs this to have test task defined
test {
println "Host system properties"
System.properties.each { k,v->
println "$k = $v"
}
systemProperty 'db.test.mode', System.getProperty("db.test.mode", "EMBEDDED")
println "Gradle system properties"
systemProperties.each { k,v->
@mosheeshel
mosheeshel / build.gradle
Created February 13, 2017 09:37
outputs std output when gradle test (usually swallowed), if you have logging in tests and test related code which you want to see during the test run, add this to the test block in gradle
test {
testLogging.showStandardStreams = true
testLogging.exceptionFormat = 'full'
}