This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"strings" | |
"path/filepath" | |
) | |
func fileNameWithoutExtension(fileName string) string { | |
return strings.TrimSuffix(fileName, filepath.Ext(fileName)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "os" | |
func makeDirectoryIfNotExists(path string) error { | |
if _, err := os.Stat(path); os.IsNotExist(err) { | |
return os.Mkdir(path, os.ModeDir|0755) | |
} | |
return nil | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSMutableArray *indexPathsToDelete = [NSMutableArray new]; | |
for (Object *object in newObjects) | |
{ | |
if (![currentObjects containsObject:object]) { | |
int row = [newObjects indexOfObject:object]; | |
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:0]; | |
[indexPathsToDelete addObject:indexPath]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo netstat -plnt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A find Tutorial and Primer: https://danielmiessler.com/study/find/ | |
find . -name '*.jpg' | |
# find only directories | |
find . -name 'foo' -type d | |
# find only files | |
find . -name 'foo' -type f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tar cvf file.tar path | |
tar cvzf file.tar.gz path | |
tar cvjf file.tar.bz2 path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
identify -format '%[m]' file.jpg[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
identify -format '%[fx:w]x%[fx:h]' file.jpg[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "os" | |
func writeStringToFile(path string, s string) error { | |
file, err := os.Create(path) | |
if err != nil { | |
return err | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//usr/bin/env go run $0 -- "$@"; exit $? |
NewerOlder