Skip to content

Instantly share code, notes, and snippets.

View xhawk's full-sized avatar
💭
Fiercely coding stuff

Tomi Savolainen xhawk

💭
Fiercely coding stuff
View GitHub Profile
@xhawk
xhawk / repeat.js
Created December 29, 2017 12:10
Repeat a function n times in 1 second or bail out if condition is met
const repeat = (fn, cond, counter) => {
console.log(counter);
if (counter == 0 || cond(1)) {
return;
} else {
setTimeout(() => {
fn();
repeat(fn, cond, counter - 1);
}, 1000);
}
let actionCreators {
save: (asd: string): SetSensorAction => {
return {type: "SET_SENSOR", payload: asd}
}
}
type EditProps =
RouteComponentProps<{}>
& type actionCreators
@xhawk
xhawk / gist:5661969
Created May 28, 2013 10:58
List all the portlets in company 10180
import com.liferay.portal.model.*;
import com.liferay.portal.kernel.plugin.*;
import com.liferay.portal.service.*;
import com.liferay.portal.util.*;
List portlets = PortletLocalServiceUtil.getPortlets(10180, false, false);
//portlets = ListUtil.sort(portlets, new PortletTitleComparator(application, locale));
int total = portlets.size();
for (int i = 0; i < total; i++) {
Portlet portlet = portlets.get(i);
@xhawk
xhawk / deleteNode
Created March 14, 2013 11:36
Deletes a node from Alfresco
import org.alfresco.repo.security.authentication.AuthenticationUtil
import org.alfresco.service.cmr.repository.NodeRef
import org.alfresco.service.cmr.repository.NodeService
NodeService nodeService = serviceRegistry.getNodeService();
AuthenticationUtil.runAsSystem([ doWork: {
nodeService.deleteNode(new NodeRef("workspace://SpacesStore/86131ef6-4543-41d6-bc3e-4e18f1ac89fb"));
} ] as AuthenticationUtil.RunAsWork);
@xhawk
xhawk / SeleniumIETest.java
Created November 16, 2012 15:09
Selenium Grid test with IE
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.net.URL;
public class SeleniumIETest {
/**
* Discovers all JUnit tests and runs them in a suite.
*/
@RunWith(AllTestsRunner.class)
public final class TestSuite {
}
@xhawk
xhawk / MyTest.java
Created May 15, 2012 19:25
Ite testi
import com.opera.core.systems.OperaDesktopDriver;
import org.junit.Rule;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
public class MyTest {
private WebDriver driver;
@Rule public ScreenshotRule screenshotRule = new ScreenshotRule();
@xhawk
xhawk / ScreenshotRule.java
Created May 15, 2012 19:24
ScreenshotRule
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
public class ScreenshotRule implements TestRule {
public Statement apply(final Statement statement, final Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {