Lage insertlinjer med økende ID fra MySQL-resultat
[info]neu242
select concat("INSERT INTO mytable(id, value) VALUES ('", @rownum := @rownum + 1, "','", result_value, "');") 
  from (SELECT result_value FROM othertable) o, (SELECT @rownum := 7000040000) r;
Bruk mysql -B eller --raw for å unngå |-er i resultatet.
Tags: , , ,
  • Add to Memories

Koble til serieport i en VirtualBox-gjest
[info]neu242
I VirtualBox:

* Sett opp COM1 » Host pipe » /tmp/com1
* Start gjest

I terminal på vert:
$ socat UNIX-CONNECT:/tmp/com1 TCP-LISTEN:8040
$ telnet localhost 8040


Takk til http://technostuff.blogspot.com/2008/10/piped-serial-port-on-virtualbox.html
  • Add to Memories

Framgangsindikator for dd
[info]neu242
FreeBSD / MacOSX:
$ kill -INFO <PID>  ## "-INFO" er det samme som "-s 29" (SIGINFO)

Linux:
$ kill -USR1 <PID>


Takk til http://www.linuxquestions.org/questions/linux-general-1/dd-verbose-mode-313420/#post3813861
  • Add to Memories

Apacheproxy foran andre tjenester
[info]neu242
<VirtualHost *>
    ProxyPass / http://127.0.0.1:8080/
    ProxyPassReverse / http://127.0.0.1:8080/  # Tar seg av Location-headere og slikt
    ProxyPreserveHost On  # Host-headeren klienten sendte opprettholdes (stort sett nødvendig når rammeverk genererer absolutte URL-er). 
    ProxyRequests Off     # Skrur av standard (forward) proxying
</VirtualHost>
  • Add to Memories

Hente SSL-sertifikat og legge det til JVM-en sin cacerts
[info]neu242
$ openssl s_client -connect example.com:443 2>&1 </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > example.crt
$ keytool -import -trustcacerts -alias example-crt -file ./example.crt -keystore ./cacerts
  • Add to Memories

Finn åpne porter på lokalt nettverk
[info]neu242
nmap -v -sT 192.168.1.0/24


Takk til http://www.cyberciti.biz/tips/linux-scanning-network-for-open-ports.html
  • Add to Memories

ALTER TABLE på alle tabeller i en database
[info]neu242
F.eks kjøre denne:
alter table DBname.DBfield CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

... på alle tabeller i datatabase DBname:
SELECT distinct CONCAT('alter table ', TABLE_SCHEMA, '.', TABLE_NAME, ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;') FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'DBname';


Takk til http://serverfault.com/questions/65043/alter-charset-and-collation-in-all-columns-in-all-tables-in-mysql
Tags: , ,
  • Add to Memories

Skru på WiFi på Android-mobilen automatisk når jeg er hjemme
[info]neu242
... ved hjelp av Tasker (med utsatt exit task)

Add Context » State » Phone » Cell Near » Scan (la den scanne i ti minutter mens du går litt rundt)

Enter Task:
1) Variable » Set: %HJEMME = 1
2) Net » Wifi: On

Exit Task:
1) Variable » Set: %HJEMME = 0
2) Tasks » Wait: 2 minutter
3) Net » Wifi: Off, IF %HJEMME != 1

Sett Exit Task Properties » Collision Handling » Abort Existing Task

Takk til https://groups.google.com/d/msg/tasker/KCF41tlTnEk/dRF6Hq8ZgDEJ
  • Add to Memories

Bygge Growl 1.3.x
[info]neu242
1) Åpne Keychain Access.app » applikasjonsmeny » Certificate Assistant » Create a certificate
    navn: 3rd Party Mac Developer Application: The Growl Project, LLC
    type: kodesignering.

2) Last ned og bygg:
hg clone https://code.google.com/p/growl/
cd growl
xcodebuild -project Growl.xcodeproj -target Growl.app -configuration Release
open build/Release
3) Kopier til /Applications og kjør

Takk til http://pragmactic-osxer.blogspot.com/2011/11/building-growl.html
  • Add to Memories

Slette gammel sti fra git-repository for alltid
[info]neu242
Gamle filer kan ta opp plass i et git-repo, selv om de ikke er synlige lengre. Her slettes myapp/deletethis/.
git remote rm origin  
git filter-branch --index-filter 'git rm --cached --ignore-unmatch -r myapp/deletethis/' -- --all

git update-ref -d refs/original/refs/heads/master  ## Viktig: sletter referanse til gammel master
git reflog expire --expire=now --all

git gc --aggressive --prune=now

NB: Alle som har tilgang til repo må klone på nytt etter dette er pushet! Evt. pushe til et nytt repo og stenge det gamle...
Tags: , ,
  • Add to Memories

You are viewing [info]neu242's journal