Skip to content

Instantly share code, notes, and snippets.

@cjmamo
cjmamo / Gemfile
Last active March 6, 2023 08:50
Dynamically Create BitCoin Wallets & Payment Pages on Coinbase in Ruby
...
# remember to use the forked version of coinbase-ruby: https://github.com/claudemamo/coinbase-ruby
gem "coinbase", "~> 1.3.0"
gem "oauth2", "~> 0.9.3"
@cjmamo
cjmamo / app(1).js
Last active March 15, 2017 11:29
Safely Prevent Template Caching in AngularJS
...
app.run(function($rootScope, $templateCache) {
$rootScope.$on('$viewContentLoaded', function() {
$templateCache.removeAll();
});
});
package org.ossandme;
import org.milyn.Smooks;
import javax.xml.transform.stream.StreamSource;
public class CsvToDbTransformer {
public void transform() throws Exception {
@cjmamo
cjmamo / pom.xml
Created July 1, 2015 13:18
Adding PostgreSQL to a Self-Contained Maven Build
<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">
...
<build>
...
<plugins>
...
<plugin>
<groupId>com.github.adrianboimvaser</groupId>
<?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">
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
Rule highValueOrderRule = new Rule();
Condition highValueOrderCondition = new Condition();
highValueOrderCondition.setField("price");
highValueOrderCondition.setOperator(Condition.Operator.GREATER_THAN);
highValueOrderCondition.setValue(5000.0);
// In reality, you would have multiple rules for different types of events.
// The eventType property would be used to find rules relevant to the event
highValueOrderRule.setEventType(Rule.eventType.ORDER);
#%RAML 0.8
title: Secure API
version: v1
baseUri: https://opensourcesoftwareandme.blogspot.com/api
securedBy: [apiKey]
securitySchemes:
- apiKey:
type: x-custom
description: Authentication by API key
@cjmamo
cjmamo / Listener(1).java
Last active November 9, 2015 12:35
Implementing a Replicated Token Service with JSON Web Tokens
import org.jose4j.jwk.RsaJsonWebKey;
import org.jose4j.jwk.RsaJwkGenerator;
...
private void registerPublicKey() throws Exception {
TokenServiceContext context = TokenServiceContext.getInstance();
RsaJsonWebKey rsaJsonWebKey = RsaJwkGenerator.generateJwk(2048);
rsaJsonWebKey.setKeyId(context.getNodeId());
ConfigurationDataMapper.insertConfiguration(context.getNodeId(), "PUBLIC_KEY", rsaJsonWebKey.toJson());
context.setKey(rsaJsonWebKey);
CREATE TABLE PERSON (
id bigserial primary key,
first_name varchar(255) not null,
last_name varchar(255) not null
);
SELECT * FROM
(SELECT *, DENSE_RANK() OVER (ORDER BY name, id) count FROM
(SELECT *, DENSE_RANK() OVER (ORDER BY name, id) offset_ FROM
(SELECT a.id, a.name, b.title
FROM AUTHOR a, BOOK b
WHERE a.id = b.authorId) result) result_offset
WHERE offset_ > 0) result_offset_count
WHERE count <= 2