Skip to content

Instantly share code, notes, and snippets.

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@ringoluo
ringoluo / Application.java
Last active September 17, 2021 12:19
Dynamic constructor arguments when wiring spring beans
@Configuration
@ComponentScan
@EnableAutoConfiguration
public class Application implements CommandLineRunner {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean(name = "state")
@ringoluo
ringoluo / comment.html
Created November 29, 2014 10:33
Comment Box using React
<!-- template.html -->
<html>
<head>
<title>Hello React</title>
<script src="http://fb.me/react-0.12.1.js"></script>
<script src="http://fb.me/JSXTransformer-0.12.1.js"></script>
<script src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/showdown/0.3.1/showdown.min.js"></script>
</head>
<body>
@ringoluo
ringoluo / OAuthClientExample
Last active August 29, 2015 14:13
SpringTemplate OAuth2 Client example
public class OAuthClientTest {
@Test
public void test() {
ResourceOwnerPasswordResourceDetails resource = new ResourceOwnerPasswordResourceDetails();
resource.setClientAuthenticationScheme(AuthenticationScheme.header);
resource.setId("restservice");
resource.setClientId("clientapp");
resource.setClientSecret("123456");
resource.setAccessTokenUri("http://localhost:8080/oauth/token");
@ringoluo
ringoluo / gist:bb81855c496fdfb36a11
Created January 21, 2015 08:25
reset db2 primary generated by default as identity sequence
SELECT MAX(entitlement_source_id)+1 FROM entitlement_source
ALTER TABLE entitlement_source ALTER COLUMN entitlement_source_id RESTART WITH 83;
// get status code
HttpClient client = HttpClientBuilder.create().build();
HttpResponse response = client.execute(new HttpGet(SAMPLE_URL));
int statusCode = response.getStatusLine().getStatusCode();
assertThat(statusCode, equalTo(HttpStatus.SC_OK));
// set timeout
// !!the Connection Timeout (http.connection.timeout) – the time to establish the connection with the remote host
// !!the Socket Timeout (http.socket.timeout) – the time waiting for data – after the connection was established; maximum time of inactivity between two data packets
// the Connection Manager Timeout (http.connection- manager.timeout) – the time to wait for a connection from the connection manager/pool
@ringoluo
ringoluo / AccountRepositoryTest.java
Created February 7, 2015 15:54
spring boot + spring data mongoldb + nosqlunit-mongodb
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@ActiveProfiles("test") // activate test configuration
public class AccountRepositoryTest {
private @Autowired AccountRepository accountRepo;
private @Autowired ApplicationContext applicationContext; // !!important to have it here
public @Rule MongoDbRule mongoDbRule = MongoDbRuleBuilder.newMongoDbRule().defaultSpringMongoDb(
"spring-dbname"); // name should match spring mongodb name
@ringoluo
ringoluo / jasmine cookbook.md
Last active August 29, 2015 14:15
Get started with Karma and Jasmine

Installation

  • npm install -g yo
  • npm install -g bower
  • npm install -g generator-jasmine
  • yo jasmine // in project dir
  • // so far it is web based test runner
  • // install karma as automated test runner
  • npm install -g karma
  • npm install -g generator-karma
  • yo karma —test-framework=jasmine // in project dir
@ringoluo
ringoluo / cards.css
Last active August 29, 2015 14:15
flexbox
/* Put behind .flexbox for Feature detection with Modernizr */
.flex-card-list {
display:flex;
flex-wrap:wrap;
}
.flex-card-listitem {
display:flex;
}
@ringoluo
ringoluo / gist:250762e7630ae0883c57
Created February 10, 2015 15:58
nosqlunit cookbook

Unit Testing FIRST Rules

  • Fast: no network/filesystem access
  • Isolated: independent of other tests
  • Repeatable: system has known state
  • Self-Validated:
  • Timely:

NoSqlUnit

  • modes:
    • in-memory mode: unit testing