Skip to content

Instantly share code, notes, and snippets.

@ochoto
ochoto / cursopowershell1.ps1
Created June 19, 2014 12:09
Trabajo con log de eventos y sesiones remotas
$maquinas = (1..10).ForEach{ "CURSOPS" + "{0:D2}" -f $_ }
$hace24h = (get-date).AddHours(-24)
Get-EventLog -LogName System -After $hace24h -EntryType Error,Warning -ComputerName $maquinas|select *|Out-GridView
$mexc = "CURSOPS02","CURSOPS03"
$sess = New-PSSession -ComputerName ($maquinas.Where{$mexc -notcontains $_})
$sess.ForEach{ Invoke-Command -Session $_ -ScriptBlock { dir c:\ } } |sort PSComputerName
@ochoto
ochoto / h2-chromium.js
Created July 26, 2014 10:08
EE22 - Hackit 2 - Chromium
var datos = "click;val;#password;https://hackit.ekparty.org/crx;get;text;show;#mal;#bien;NETWORK ERROR!;ajax;bind;#sendButton;ready".split(";");
function enviar(pass) {
resultado = "kk"
$[datos[10]]({
url: datos[3],
type: datos[4],
async: !1,
data: {password: pass},
dataType: datos[5],
@ochoto
ochoto / sca.py
Created July 26, 2014 19:23
raspberry
i=IP(src="10.0.2.15",dst="192.168.42.1")
r=ICMPv6EchoReply(id=0x0007,seq=300)
send(i/r)
package whoop.whoop
import java.util.concurrent.TimeUnit
import org.openjdk.jmh.annotations._
import scala.util.control.NoStackTrace
@State(Scope.Benchmark)
@BenchmarkMode(Array(Mode.AverageTime))
@ochoto
ochoto / SQLServerDialect.java
Created January 27, 2012 11:28 — forked from vgrichina/SQLServerDialect.java
Improved MSSQL dialect for Hibernate (using more appropriate data types)
/*
* Copyright © 2009, Componentix. All rights reserved.
*/
package com.componentix.hibernate.dialect;
import java.sql.Types;
/**
* A proper dialect for Microsoft SQL Server 2000 and 2005.
@ochoto
ochoto / Decrypt.java
Created April 27, 2012 06:41
Decrypt Weblogic 11g password
// From http://middlewaremagic.com/weblogic/?p=7265
// Author: René van Wijk
package middleware.magic;
import weblogic.security.internal.SerializedSystemIni;
import weblogic.security.internal.encryption.ClearOrEncryptedService;
import weblogic.security.internal.encryption.EncryptionService;
public class Decrypt {
@ochoto
ochoto / Ubuntu_Switch_Graphics.sh
Created June 19, 2012 07:35
Control hybrid graphics
#!/bin/bash
#mount -t debugfs none /sys/kernel/debug
cd /sys/kernel/debug/vgaswitcheroo
cat switch # to see which card is active
echo DDIS > switch # to go to discrete card (log off and then log in after this command)
echo DIGD > switch # to go to integrated card (log off and then log in after this command)
echo OFF > switch # to just power off the card you aren't using
@ochoto
ochoto / 2bitexpand.c
Created July 28, 2012 14:02
Expand 2 bit raw to byte
#include <stdio.h>
void expand(const char c, char b[4]) {
b[0] = c & 3;
b[1] = (c >> 2) & 3;
b[2] = (c >> 4) & 3;
b[3] = (c >> 6) & 3;
}
int main(int argc,char* argv[]) {
@ochoto
ochoto / factorion.scala
Created September 24, 2012 15:45
Factorion
object factorion extends App {
lazy val N: Stream[Int] = Stream.cons(1, N.map(_ + 1))
lazy val fact: Stream[Int] = Stream.cons(1, fact.zip(N).map(a => a._1 * a._2))
val factmap = 0 to 9 map { a => a.toString -> fact(a) } toMap
def esFactorion(n: Int) = (n.toString.toList map (c => factmap.get(c.toString).get) sum) == n
val start = System.nanoTime
import scala.annotation.tailrec
object paresmayores extends App {
def mayoresPares(numPares: Int, lte: Int) = {
val startNum = if (lte % 2 == 0) lte else lte - 1
@tailrec
def mp(numPares: Int, start: Int, listaPares: List[Int]): List[Int] = {
if (numPares == 0)