Explore Public Snippets
Found 17k snippets matching: command
public by lbottaro 901643 60 8 1
How to remove all checked out files in clearcase
# Remove ALL checked out files from view in the entire vobs cleartool lsco -cview -me -avobs -short | xargs cleartool unco -rm # Remove ALL checked out files from the current directory on only cleartool lsco -cview -me -rec -short | xargs cleartool unco -rm
public by lbottaro 529686 10 8 0
How to get the list of all the activities comparing two UCM streams in python
import os bl_old="myOldBaseline@/MyVobs" bl_new="myNewBaseline@/MyVobs" myView = "MyView" diff_act=os.popen("cleartool setview -exec \"cleartool diffbl -nmerge -activities "+bl_old+" "+ bl_new+" \" " +myView).readlines() for act in diff_act: print ("ACTIVITY: "+str(act))
public by antlong 489216 15 7 1
Extract JPG images from a PDF
#!/usr/bin/env python import sys def main(): """Extract JPG's from PSD's. Usage: python extract.py filename.pdf Note: All extracted images will be saved to the directory the script is initialized in. """ try: pdf = file(sys.argv[1], "rb").read() except Exception: print "Usage: `python extract.py filename.pdf`" return startmark, endmark = "\xff\xd8", "\xff\xd9" startfix, endfix, i, njpg = 0, 2, 0, 0 while True: istream = pdf.find("stream", i) if istream < 0: break istart = pdf.find(startmark, istream, istream+20) if istart < 0: i = istream+20 continue iend = pdf.find("endstream", istart) if iend < 0: raise Exception("Couldn't find end of stream.") iend = pdf.find(endmark, iend-20) if iend < 0: raise Exception("Couldn't find end of JPG.") istart += startfix iend += endfix jpg = pdf[istart:iend] with open("jpg%d.jpg" % njpg, "wb") as _f: _f.write(jpg) njpg += 1 i = iend print "Extracted %s JPG files." % njpg main()
public by lbottaro 341343 3 7 1
How to checkout the latest tag of a Git repository
# Get new tags from the remote git fetch --tags # Get the latest tag name latestTag=$(git describe --tags `git rev-list --tags --max-count=1`) # Checkout the latest tag git checkout $latestTag
public by emsity 262979 2 6 0
PHP script to call Python robot arm command
<?php exec( " sudo python /home/pi/arm/baseanti.py &" ); /* Redirect browser */ $gohere = "http://192.168.169.15/index3G.html"; header("Location: $gohere"); /* Make sure that code below does not get executed when we redirect. */ exit; ?>
public by fromano 269960 2 4 0
Useful commands for math in LaTeX
\newcommand{\fratop}[2]{\genfrac{}{}{0pt}{}{#1}{#2}} \newcommand{\mx}[1]{\mathbf{\bm{#1}}} % Matrix symbol \newcommand{\vc}[1]{\mathbf{\bm{#1}}} % Vector symbol \newcommand{\degree}{\ensuremath{^\circ}} % define the degree symbol \newcommand{\pder}[2]{\frac{\partial#1}{\partial#2}} % partial derivative \newcommand{\refframe}[1]{\mbox{\textless#1\textgreater}} % to denote a reference frame \DeclareMathOperator*{\argmin}{\arg\!\min} % argmin \DeclareMathOperator*{\argmax}{\arg\!\max} % argmax \DeclareMathOperator*{\dif}{\mathrm{d}} % d \DeclareMathOperator*{\half}{\frac{1}{2}} % one half \newcommand{\mat}[1]{\ensuremath{\begin{bmatrix}#1\end{bmatrix}}} % matrix \newcommand{\rank}[1]{\text{rank}(#1)} % rank \newcommand{\diag}[1]{\text{diag}(#1)} % diag \newcommand{\x}{\ensuremath{\times}}
public by skaggej 219404 2 6 0
SharePoint 2010 - List All SharePoint PowerShell Cmdlets
Get-Command -Module Microsoft.SharePoint.PowerShell | Select Name >> C:\AllSharePointPowerShellCmdlets.txt
public by jaehoon 204804 1 4 0
맥의 기본 한글 글꼴을 바꿔주는 스크립트 - A script for changing Mac OS X's default font fallbacks
#!/usr/bin/env bash # A script for changing Mac OS X's default fonts # Author: Jaeho Shin <netj@sparcs.org> # Created: 2011-07-22 ### MacOSXDefaultFontFallbacksChanger ######################################### ## Mac OS X 기본 글꼴 설정 변경 도구 – 1.2.1 (2012-08) ## http://netj.github.com/MacOSXDefaultFontFallbacksChanger ############################################################################### # Specify sets of substitutions between these two lines of hashes: ### H: 함초롬 돋움 & 바탕 (한컴) ############################################## # Home: http://faq.ktug.or.kr/faq/%C7%D4%C3%CA%B7%D2%C3%BC/GSUB # Home: http://www.haansoft.com/hnc/event/ham/index.htm ## Download fonts from http://ftp.ktug.or.kr/KTUG/hcr-lvt/Hamchorom-LVT.zip ## Keep zip archive at ~/.fonts/HCR/Hamchorom-LVT.zip ## Change font AppleGothic=HCR Dotum LVT ## Change font AppleMyungjo=HCR Batang LVT ############################################################################### ### N: 나눔 고딕 & 명조 (네이버) ############################################## # Home: http://hangeul.naver.com/font ## Change font AppleGothic=Nanum Gothic ## Change font AppleMyungjo=Nanum Myeongjo ############################################################################### ### S: 산돌 고딕네오 & 나눔 명조 – 10.8+ 또는 산돌고딕네오가 설치된 경우에만 ## # Home: http://neo.sandoll.co.kr/ ## Change font AppleGothic=AppleSDGothicNeo-Regular ## Change font AppleMyungjo=Nanum Myeongjo ############################################################################### ### M: Finder에선 불완전한 뫼비우스 (SK Telecom) ############################## # Home: http://www.tworld.co.kr/outsitens.jsp ## Download fonts from http://www.tworld.co.kr/html/t/download/Moebius_Regular_kor.zip ## Keep zip archive at ~/.fonts/Moebius/Moebius_Regular_kor.zip ## Change font AppleGothic=Moebius Korea # Download fonts from http://www.tworld.co.kr/html/t/download/Moebius_Bold_kor.zip # Keep zip archive at ~/.fonts/Moebius/Moebius_Bold_kor.zip # Change font AppleGothic=Moebius Korea Bold ############################################################################### ### O: Finder에선 불완전한 서울남산체 & 한강체 (서울서체) ##################### # Home: http://design.seoul.go.kr/dscontent/designseoul.php?MenuID=490&pgID=237 ## Download fonts from http://design.seoul.go.kr/js/boardFileDown.php?model=PolicyData&id=251&field_path=file_path&field_name=file_name1&no=1&is_crypt=false ## Keep zip archive at ~/.fonts/SeoulFonts/SeoulFonts_TTF.zip ## Change font AppleGothic=SeoulNamsan ## Change font AppleMyungjo=SeoulHangang ############################################################################### ### A: Finder에선 불완전한 아리따 돋움 (아모레퍼시픽) ######################### # Home: http://www.amorepacific.com/about/about_font.jsp ## Download fonts from http://www.amorepacific.com/resources/download/about/font/arita_ttf.zip ## Keep zip archive at ~/.fonts/Arita/arita_ttf.zip ## Change font AppleGothic=Arita\-dotum(TTF)\-SemiBold ############################################################################### # No need to modify below this line, unless you know what you're doing. set -eu # sanitize environment PATH=/usr/bin:/bin CDPATH= clear # some vocabularies error() { echo "$@" >&2; } pause() { read -t${1:-5} || true; } hr() { echo -------------------------------------------------------------------------------; } indent() { sed '/^-/! s/^/ /'; } show-header() { sed -ne '/^### MacOSXDefaultFontFallbacksChanger ####*$/,/^####*$/ { /^## / s/^## //p; }' <"$0" } ProductName=$(sw_vers -productName) ProductVersion=$(sw_vers -productVersion) show-warning() { echo " WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING" echo " WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING" echo " WARNING WARNING" echo " WARNING 무슨 일이 생길 지 모르니 섣불리 진행하지 마십시오!!! WARNING" printf " WARNING 이 도구는 %14s에서 시험해보지 않았습니다! WARNING\n" "$ProductName $ProductVersion" echo " WARNING 컴퓨터를 더 이상 못 쓰는 상태로 만들 수도 있습니다!! WARNING" echo " WARNING WARNING" printf " WARNING This tool has not been tested on: %14s !! WARNING\n" "$ProductName $ProductVersion" echo " WARNING Your system may become unusable after modifications! WARNING" echo " WARNING DO NOT PROCEED UNLESS YOU KNOW WHAT YOU ARE DOING!!! WARNING" echo " WARNING WARNING" echo " WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING" echo " WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING" hr } # fontsets embedded in comments list-fontsets() { sed -ne '/^### [A-Z0-9]: .* #*$/,/^####*$/ { /^### / { s/^### //; s/ #*$//g; p; }; }' <"$0" } fontset() { local key=$1 if grep -q '^### '"$key"': ' "$0"; then sed -ne '/^### '"$key"': /,/^####*$/ { /^## / s/^## //p; }' <"$0" else false fi } substitute() { vimcmds+=("+%s/$1/$2/g"); } compile-fontset() { local line= i=0 while read line; do case $line in "Download fonts from "*) echo "URL='${line#Download fonts from }'" ;; "Keep zip archive at "*) echo "LocalPath=${line#Keep zip archive at }" ;; "Change font "*) local patt=${line#Change font } echo "substitute '${patt%%=*}' '${patt#*=}'" ;; *) error "Syntax error for $key: $line" >&2 exit 2 ;; esac let i++ done if [ $i -eq 0 ]; then echo "Empty rules for $key:" >&2 exit 2 fi } # property lists that control the default font fallbacks Plists=( /System/Library/Frameworks/ApplicationServices.framework/Versions/Current/Frameworks/CoreText.framework/Versions/Current/Resources/DefaultFontFallbacks.plist /System/Library/Frameworks/AppKit.framework/Versions/Current/Resources/NSFontFallbacks.plist ) # version of this script # check compatibility with current Mac OS X version IsCompatible=false if [ x"$ProductName" = x"Mac OS X" ]; then case $ProductVersion in 10.7|10.7.*|10.8|10.8.*) # Lion, Mountain Lion will probably remain compatible after minor updates IsCompatible=true ;; *) # unsure about other versions, display warning ;; esac fi # the main loop interact() { # listen to user for what to do { hr show-header hr $IsCompatible || show-warning list-fontsets hr echo "R: 원상복구 / Reset to Original settings" echo "Q: 종료 / Quit " hr } | indent read -n1 -p "키를 누르세요 / Press key: " key echo echo key=$(tr a-z A-Z <<<"$key") # ignoring case of input key, case $key in Q) # bye bye exit ;; R) # revert modifications echo 원상복구중 / Reverting to original settings... for plist in "${Plists[@]}"; do if [ -e "$plist.orig" ]; then sudo cp -pfv "$plist.orig" "$plist" fi done echo 원래 설정을 적용하려면 재시동하거나 응용프로그램을 다시 띄웁니다. echo 경고: /System/Library/Fonts/ 아래에는 일부 파일이 남아있을 수 있습니다. echo Now reboot or restart your apps to use the Original settings. echo Warning: You may need to remove files from /System/Library/Fonts/ by hand. pause exit ;; *) # display details if fontset=$(list-fontsets | grep "^$key: "); then fontset=${fontset#$key: } { hr echo "$fontset" hr fontset "$key" hr } | indent else echo "$key: 잘못된 키 / Undefined key" >&2 echo return fi # give user a chance to abort read -n1 -p "위 설정을 진행할까요? Continue to change as above? (y or n) "; echo; echo case $REPLY in [yY]) true ;; *) return ;; esac # read the rules for fontset URL= LocalPath= vimcmds=() eval "$(fontset "$key" | compile-fontset)" # download and install ttfs if [ -n "$URL" -a -n "$LocalPath" ]; then ( LocalDir=`dirname "$LocalPath"` LocalName=`basename "$LocalPath"` mkdir -p "$LocalDir" cd "$LocalDir" echo 글꼴 받는 중 / Downloading fonts from $URL... completeFlag="$LocalName.complete" if [ -e "$completeFlag" ]; then # avoid downloading twice if we have a complete one rm -f "$completeFlag" curl -#LRkz "$LocalName" -o "$LocalName" "$URL" || curl -#LRko "$LocalName" "$URL" else # otherwise, try resuming the previous one curl -#LRC - -o "$LocalName" "$URL" || curl -#LRko "$LocalName" "$URL" fi touch "$completeFlag" tmp=tmp ditto -x -k "$LocalName" $tmp || true echo 글꼴 설치 중 / Installing fonts to /System/Library/Fonts/... ( cd $tmp find . -name '*.[ot]t[fc]' -exec sudo install -vm a=r {} /System/Library/Fonts \; ) rm -rf $tmp ) fi # modify plist files echo 기본 글꼴 설정을 변경합니다 / Changing default font fallbacks... for plist in "${Plists[@]}"; do if [ -e "$plist.orig" ]; then # XXX following line prevents combination of independent changes :( # however, this lets users to change fontsets without resetting to original sudo cp -pf "$plist.orig" "$plist" else sudo cp -npv "$plist" "$plist.orig" fi echo " $plist" sudo plutil -convert xml1 "$plist" sudo vim -n +"set nobackup" "$plist" "${vimcmds[@]}" +wq sudo plutil -convert binary1 "$plist" done echo "$fontset"을 쓰려면 재시동하거나 응용프로그램을 다시 시작 하십시오. echo Now reboot or restart your apps to use "$fontset". pause 7 exit ;; esac } while true; do interact; done
public by Geometry 148405 0 3 0
GetCommandBuffer: Gets the bytes representing the specified command. returned buffer can be used to streamline multiple writes into one Write on the Socket using the <see cref="M:Enyim.Caching.Memcached.PooledSocket.Write(IList<ArraySegment<b...
using System; using System.IO; using System.Text; using System.Collections.Generic; /// <summary> /// Gets the bytes representing the specified command. returned buffer can be used to streamline multiple writes into one Write on the Socket /// using the <see cref="M:Enyim.Caching.Memcached.PooledSocket.Write(IList<ArraySegment<byte>>)"/> /// </summary> /// <param name="value">The command to be converted.</param> /// <returns>The buffer containing the bytes representing the command. The command must be terminated by \r\n.</returns> /// <remarks>The Nagle algorithm is disabled on the socket to speed things up, so it's recommended to convert a command into a buffer /// and use the <see cref="M:Enyim.Caching.Memcached.PooledSocket.Write(IList<ArraySegment<byte>>)"/> to send the command and the additional buffers in one transaction.</remarks> public unsafe static IList<ArraySegment<byte>> GetCommandBuffer(string value) { var data = new ArraySegment<byte>(Encoding.ASCII.GetBytes(value)); return new ArraySegment<byte>[] { data }; }