Skip to content

Instantly share code, notes, and snippets.

@paulogaspar7
paulogaspar7 / bash-to-zsh-hist.py
Created July 31, 2020 19:21 — forked from muendelezaji/bash-to-zsh-hist.py
Convert Bash history to Zsh history
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This is how I used it:
# $ cat ~/.bash_history | python bash-to-zsh-hist.py >> ~/.zsh_history
import sys
import time
@paulogaspar7
paulogaspar7 / SmallRomans.scala
Last active April 24, 2016 20:02
Romans number parser with (some) validation. Not beautiful, not efficient, just small...
def table(i: Char, v: Char, x: Char) = Seq("", s"$i", s"$i$i", s"$i$i$i", s"$i$v", s"$v", s"$v$i", s"$v$i$i", s"$v$i$i$i", s"$i$x" )
val x1000 = Seq("", "M", "MM", "MMM", "MMMM")
val x100 = table('C', 'D', 'M')
val x10 = table('X', 'L', 'C')
val x1 = table('I', 'V', 'X')
val lookup: Map[String, Int] = (1 to 4999).foldLeft(Map.empty[String, Int]) {
case (m, d) => m.updated(x1000(d / 1000) + x100((d % 1000) / 100) + x10((d % 100) / 10) + x1(d % 10), d)
}
var Col = require('react-bootstrap/lib/Col')
var PageHeader = require('react-bootstrap/lib/PageHeader')
var React = require('react')
var Row = require('react-bootstrap/lib/Row')
var {connect} = require('react-redux')
var {reduxForm} = require('redux-form')
var DateInput = require('./DateInput')
var FormField = require('./FormField')
var LoadingButton = require('./LoadingButton')
public class SpringExceptionTranslationExecuteListener
extends DefaultExecuteListener {
/** {@inheritDoc} */
@Override
public void exception(ExecuteContext ctx) {
String name = productName(ctx.configuration().dialect());
/* Prefer product name, if available. */
SQLExceptionTranslator translator = (name != null)
If you want, I can try and help with pointers as to how to improve the indexing speed you get. Its quite easy to really increase it by using some simple guidelines, for example:
- Use create in the index API (assuming you can).
- Relax the real time aspect from 1 second to something a bit higher (index.engine.robin.refresh_interval).
- Increase the indexing buffer size (indices.memory.index_buffer_size), it defaults to the value 10% which is 10% of the heap.
- Increase the number of dirty operations that trigger automatic flush (so the translog won't get really big, even though its FS based) by setting index.translog.flush_threshold (defaults to 5000).
- Increase the memory allocated to elasticsearch node. By default its 1g.
- Start with a lower replica count (even 0), and then once the bulk loading is done, increate it to the value you want it to be using the update_settings API. This will improve things as possibly less shards will be allocated to each machine.
- Increase the number of machines you have so
WeakHashMap<Integer, String> map = new WeakHashMap<Integer, String>();
map.put(new Integer(10), "aaa"); // remove entry
// map.put(10, "aaa"); // don't remove entry
// map.put(Integer.valueOf(10), "aaa"); // don't remove entry
for (int i = 0; i < Integer.MAX_VALUE; i++) {
if (map.size() != 0) {
System.out.println("At iteration " + i + " the map still holds the reference to object");
} else {
@paulogaspar7
paulogaspar7 / bash.sh
Created January 6, 2014 02:16 — forked from hugocf/bash.sh
#!/usr/bin/env bash
# Created by Hugo Ferreira <hugo@mindclick.info> on isoD.
# Copyright (c) 2012 Mindclick. All Rights Reserved.
# Licensed under the BSD License: http://creativecommons.org/licenses/BSD
readonly BASEDIR=$(cd "$(dirname "$0")" && pwd) # where the script is located
readonly CALLDIR=$(pwd) # where it was called from
# Script configuration
readonly CONSTANT="value"
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<target name="building">
<echo>
---------------------------------------------------

Generate Appcache Manifest (incl. xhr) in Chrome DevTools

  1. Open your Chrome Developer Tools
  2. Navigate to the Network tab
  3. Just right click into the panel and choose Copy ALL as HAR (maybe the page needs a reload)
  4. Switch to the console tab and save your HAR data in a variable. (var data = cmd + v)
  5. Now let's create the cache manifest:
console.log('CACHE MANIFEST\n\nCACHE:');