Skip to content

Instantly share code, notes, and snippets.

View liufsd's full-sized avatar
🎯
Focusing

liupeng liufsd

🎯
Focusing
View GitHub Profile
// .h
@interface AMPNavigationBar : UINavigationBar
@end
// .m
@interface AMPNavigationBar ()
package org.sazabi.lib.preference;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.preference.Preference;
def java_string_hashcode(s):
h = 0
for c in s:
h = (31 * h + ord(c)) & 0xFFFFFFFF
return ((h + 0x80000000) & 0xFFFFFFFF) - 0x80000000
@liufsd
liufsd / Events.h
Last active September 17, 2015 13:18
he Keyboard Reference Numbers are listed in Events.h, which in the HIToolbox framework. To find it, you can do a filename search of /System/Library. On my 10.11 system, the file is at/A/Frameworks/HIToolbox.framework/Versions/A/Headers; http://dbachrach.com/blog/2005/11/program-global-hotkeys-in-cocoa-easily/
/*
File: HIToolbox/Events.h
Contains: Event Manager Interfaces.
Copyright: © 1985-2008 by Apple Computer, Inc., all rights reserved
Bugs?: For bug reports, consult the following page on
the World Wide Web:
{"status":0,"message":null,"data":[{"id":"12acad12","imageUrl":"https://mis.hujiang.com/project/picture/spic/u32794313.jpg","summary":"双语文章及学习经验,提升语言修养","title":"阅读"},{"id":"11ccc11","imageUrl":"https://mis.hujiang.com/project/picture/spic/u32794313.jpg","summary":"培养语感,锻炼语言总体把控能力","title":"听力"},{"id":"11123ddd333","imageUrl":"https://mis.hujiang.com/project/picture/spic/u32794313.jpg","summary":"逐句听与练,夯实听力基础","title":"听写"},{"id":"44ssssrrrrf","imageUrl":"https://mis.hujiang.com/project/picture/spic/u32794313.jpg","summary":"教学练测体系化学习课程","title":"课程"}]}
@liufsd
liufsd / idea
Created December 10, 2015 06:04 — forked from chrisdarroch/idea
Open a project in IntelliJ IDEA from your command line!
#!/bin/sh
# check for where the latest version of IDEA is installed
IDEA=`ls -1d /Applications/IntelliJ\ * | tail -n1`
wd=`pwd`
# were we given a directory?
if [ -d "$1" ]; then
# echo "checking for things in the working dir given"
wd=`ls -1d "$1" | head -n1`
@liufsd
liufsd / ij.sh
Created December 10, 2015 06:04 — forked from suya55/ij.sh
Open a project in IntelliJ IDEA from your command line! Raw
#!/bin/sh
# check for where the latest version of IDEA is installed
IDEA=`ls -1d /Applications/IntelliJ\ * | tail -n1`
wd=`pwd`
# Setup your working directory. Edit 'work' to your working directory.
working_dir=`ls -1d ~/work/$1 | head -n1`
# were we given a directory?
if [ -d "$1" ]; then
@implementation LogProvider
+(void)writeLogFile:(NSString* )message {
NSString *applicationCacheDirectory = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
NSDateFormatter* formate = [[NSDateFormatter alloc] init];
[formate setDateFormat:@"yyyy-MM-dd"];
NSString* logFolder = [applicationCacheDirectory stringByAppendingPathComponent:@"SKPhotoCloudUploadLog"];
NSString* finalPath = [logFolder stringByAppendingPathComponent: [NSString stringWithFormat:@"%@.log",[formate stringFromDate:[NSDate new]]]];
NSFileHandle *output = [NSFileHandle fileHandleForWritingAtPath:finalPath];
if(output == nil) {
if (![[NSFileManager defaultManager] fileExistsAtPath:logFolder]) {
STATUS=`defaults read com.apple.finder AppleShowAllFiles 2>/dev/null`
if [ "$STATUS" == TRUE ]; then
STATUS=`osascript -e 'tell app "Finder" to display alert "Finder is showing hidden files." buttons {"Cancel", "Hide"}'`
else
STATUS=`osascript -e 'tell app "Finder" to display alert "Finder is not showing hidden files." buttons {"Cancel", "Show"}'`
fi
if [ "$STATUS" == "button returned:Show" ]; then
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
elif [ "$STATUS" == "button returned:Hide" ]; then
on run
set myVar to do shell script "defaults read com.apple.finder AppleShowAllFiles 2>/dev/null"
if myVar is "1" then
#display dialog "cuttent is show. will hide it"
do shell script "defaults write com.apple.finder AppleShowAllFiles 0"
do shell script "killall Finder"
else
#display dialog "current hidden. will show it"
do shell script "defaults write com.apple.finder AppleShowAllFiles 1"