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 / DockerContainerRule.java
Created October 2, 2014 14:31
JUnit @rule for starting a docker container from within an Integration test
package rules;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.spotify.docker.client.DefaultDockerClient;
import com.spotify.docker.client.DockerClient;
import com.spotify.docker.client.DockerException;
import com.spotify.docker.client.messages.ContainerConfig;
import com.spotify.docker.client.messages.ContainerCreation;
import com.spotify.docker.client.messages.HostConfig;
@mosheeshel
mosheeshel / RabbitContainerRule.java
Created October 2, 2014 14:33
JUnit @rule for starting a RabbitMQ container (based on other rule - see comments)
package rules;
import com.google.common.collect.ImmutableMap;
import org.eclipse.jdt.launching.SocketUtil;
import java.util.HashMap;
import java.util.Map;
/**
* Created with IntelliJ IDEA.
@mosheeshel
mosheeshel / RabbitIntegrationTest.java
Created October 2, 2014 14:41
Demo Integration test using RabbitDockerContainer @rule
package integration;
import com.kenshoo.trackingfront.configuration.RabbitConfiguration;
import com.kenshoo.trackingfront.rabbitmq.RabbitConnectionFactory;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import org.junit.*;
import org.junit.rules.ExpectedException;
import static org.mockito.Matchers.anyString;