Skip to content

Instantly share code, notes, and snippets.

@ramons03
ramons03 / gist:1398030
Created November 27, 2011 19:33
Devuelve el maximo valor de repeticiones de acuerdo a una propiedad del objeto
public static int contarRepetidos(ArrayList<Objeto> a) {
Map<Integer, Integer> freqMap = new HashMap<Integer, Integer>();
for (Objeto obj : a) {
freqMap.put(obj.getValor(), (freqMap.get(obj.getValor()) == null ? 1 : (freqMap.get(obj.getValor()) + 1)));
}
return Collections.max(freqMap.values());
}
@ramons03
ramons03 / dabblet.html
Created February 15, 2012 12:39
holamundowebapp
<!-- content to be placed inside <body>…</body> -->
<!DOCTYPE html>
<html>
<head>
<title>Hola mundo desde el titulo</title>
</head>
<body>
<h1>Hola Mundo</h1>
<br />
<h1>HTML Hypertext Markup Language</h1>
@ramons03
ramons03 / dabblet.css
Created March 4, 2012 17:17
cursowebappcss
body{
font-family:Tahoma,Arial,sans-serif;
font-size: 13px;
color:black;
background:white;
margin:8px;
}
h1{
font-size:19px;
margin-top:15px;
@ramons03
ramons03 / setJSVarFromMVCJson.js
Last active December 19, 2015 18:19
Parse a json result from asp MVC controller and set a variable in javascript with an attribute from the json object.
function getData(url) {
var data;
$.ajax({
async: false, //thats the trick
url: url,
dataType: 'json',
success: function (response) {
data = response;
}
});
@ramons03
ramons03 / OptimizedMathSquare
Created July 16, 2013 15:58
Here’s how to compute sqrt(x*x + y*y) without risking overflow.
max = maximum(|x|, |y|)
min = minimum(|x|, |y|)
r = min / max
return max*sqrt(1 + r*r)
@ramons03
ramons03 / flashtitle.js
Last active January 11, 2017 12:57
Flashing HTML Title Script
(function () {
var original = document.title;
var timeout;
var defaultTimes = 5;
window.flashTitle = function (newMsg, howManyTimes) {
function step() {
document.title = (document.title == original) ? newMsg : original;
@ramons03
ramons03 / yearupdate.sql
Last active January 11, 2017 14:08
Change Year only to a date column in SQL.
--SQL Server
UPDATE table SET DateToModify = DATEADD(YEAR, -1, DateToModify)
where YEAR(DateToModify) = 2015
--MySQL
UPDATE table SET DateToModify = DATE_ADD(DateToModify, INTERVAL 1 YEAR)
where YEAR(DateToModify) = 2015
@ramons03
ramons03 / massrename.bat
Created January 11, 2017 14:32
Mass rename files windows command prompt
REM dir / -B > fileList.txt
REM for /f "tokens=1,2,3" %i in (fileList.txt) DO ren "%i %j %k" %k
for /f "tokens=1,2,3" %i in ('dir / -B') DO ren "%i %j %k" %k
@ramons03
ramons03 / linqlambda.cs
Created May 31, 2017 14:09
LINQ async options with lambda using whenall
var tasks = foos.Select(DoSomethingAsync).ToList();
await Task.WhenAll(tasks);
var results = await Task.WhenAll(tasks);
return await Task.WhenAll(tasks);
var tasks = foos.Select(foo => DoSomethingAsync(foo)).ToList();
@ramons03
ramons03 / VisualStudio.gitignore
Created June 19, 2017 15:16
VisualStudio gitignore
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates