Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
DIR="$( cd "$( dirname "$0" )" && pwd )"
pushd "$DIR" > /dev/null
tar -z -p -c -f `date +"%Y%m%d-%H%M%S"`.www.gz -C / -P /etc/httpd/ /srv/www/
BACKUP_CNT=`ls *.www.gz | wc -l`
if [ "$BACKUP_CNT" -gt "15" ]; then
LAST_BACKUP=`ls *.www.gz | sort | head -n 1`
rm -f $LAST_BACKUP
#!/bin/bash
DIR="$( cd "$( dirname "$0" )" && pwd )"
pushd "$DIR" > /dev/null
su -l -c "pg_dumpall" postgres | gzip > `date +"%Y%m%d-%H%M%S"`.sql.gz
BACKUP_CNT=`ls *.sql.gz | wc -l`
if [ "$BACKUP_CNT" -gt "15" ]; then
LAST_BACKUP=`ls *.sql.gz | sort | head -n 1`
#!/bin/bash
if [ -z "$1" ]; then
echo "$0: need an input set file";
exit 1;
fi
if [ ! -f "$1" ]; then
echo "$0: file not found '$1'";
exit 1;
fi
@tsohr
tsohr / ImageInsert.bas
Last active August 29, 2015 14:07
Insert pictures from a DIR expression on a MS Word docs. Resize/crop pictures from a selection basis.
Option Explicit
Public pictureSizeWidth As Integer
Public pictureSizeHeight As Integer
Public Sub insertPicture(file As String, width As Integer)
Dim shp As InlineShape
Set shp = ActiveDocument.InlineShapes.AddPicture( _
FileName:=file, _
LinkToFile:=False, _
SaveWithDocument:=True)
@tsohr
tsohr / !tomcat-rewrite.cpp
Last active August 29, 2015 14:15
tomcat_rewrite
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <vector>
#include <iterator>
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <cctype>
@tsohr
tsohr / !Melzi upload
Created February 18, 2015 08:25
Sanguino for arduino 1.6.0
cd "C:\Program Files (x86)\Arduino"
"hardware\tools\avr\bin\avrdude"
-C"C:\Program Files (x86)\Arduino\hardware\tools\avr\etc\avrdude.conf"
-v -patmega1284p -Pcom5 -b19200
-c avrisp -Uflash:w:C:\USERS\ADMINI~1\APPDATA\LOCAL\TEMP\build8351945056164552931.tmp/Marlin.cpp.hex:i
@tsohr
tsohr / cygwin_settings.sh
Last active May 31, 2022 09:48
My cygwin initial preference
# place setup-x86_64.exe under the cygwin root directory
#apt-cyg
/setup-x86_64.exe -q -P wget,tar,qawk,bzip2,subversion,vim
wget 'http://rawgit.com/transcode-open/apt-cyg/master/apt-cyg'
chmod a+x apt-cyg
mv apt-cyg /bin/
#/etc/profile
{
"chart_data": [
{
"date": "2015-08-10 08:38:51.953332",
"inside": "25.187",
"outside": "19.78"
},
{
"date": "2015-08-10 08:43:52.259654",
"inside": "25.125",
Sub r()
Dim s As Workbook
For i = 1 To Application.Workbooks.Count
Set s = Application.Workbooks.Item(i)
s.Activate
s.Sheets(1).Range("A1").Select
Cells.Replace What:="오전", Replacement:="AM", LookAt:=xlPart, SearchOrder _
@tsohr
tsohr / ImageInsert.bas
Created November 12, 2015 11:57
MS Excel
' http://stackoverflow.com/a/8525125/592817
Sub InsertImage()
Dim urlColumn As Range
Dim imgColumn As Range
Dim fp As String
Set urlColumn = Worksheets(1).UsedRange.Columns("W")
Set imgColumn = Worksheets(1).UsedRange.Columns("X")
Dim i As Long
For i = 2 To urlColumn.Cells.Count