Skip to content

Instantly share code, notes, and snippets.

View 0oneo's full-sized avatar
😃
Go Li

0oneo 0oneo

😃
Go Li
  • 阿里本地生活
  • Shanghai
View GitHub Profile
@0oneo
0oneo / gist:72c7120ffd411a8a314b3db37b37216a
Created June 18, 2017 03:19
get all magnet links from a web page
$("a[href*='magnet']").map(function() {return this.href}).get().join("\n")
@0oneo
0oneo / bootstrap_pre_extra_blank.js
Created May 2, 2017 03:44
remove bootstrap extra blank caused by document outline
<script>
/*!
*** prettyPre ***/
(function( $ ) {
$.fn.prettyPre = function( method ) {
var defaults = {
ignoreExpression: /\s/ // what should be ignored?
@0oneo
0oneo / common_regular_expression.rb
Created February 3, 2016 07:09
some common used regular expression collected from the web
[\x{4e00}-\x{9fa5}] // used for match Chinese character | 用来匹配中文
@0oneo
0oneo / add_hair_line.m
Last active December 25, 2015 12:13
add hairline to a view
//| ----------------------------------------------------------------------------
// Called when the view is about to be displayed. May be called more than
// once.
//
- (void)willMoveToWindow:(UIWindow *)newWindow {
// Use the layer shadow to draw a one pixel hairline under this view.
[self.layer setShadowOffset:CGSizeMake(0, 1.0f/UIScreen.mainScreen.scale)];
[self.layer setShadowRadius:0];
// UINavigationBar's hairline is adaptive, its properties change with
@0oneo
0oneo / .m
Created August 22, 2015 04:21
cancel dispatch after
//
// SpacemanBlocks.h
//
// Created by Jerry Jones on 12/11/11.
// Copyright (c) 2011 Spaceman Labs. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef void(^SMDelayedBlockHandle)(BOOL cancel);
@0oneo
0oneo / whatsapp-image-compression
Last active August 29, 2015 14:27 — forked from akshay1188/whatsapp-image-compression
Whatsapp like image compression
- (UIImage *)compressImage:(UIImage *)image{
float actualHeight = image.size.height;
float actualWidth = image.size.width;
float maxHeight = 600.0;
float maxWidth = 800.0;
float imgRatio = actualWidth/actualHeight;
float maxRatio = maxWidth/maxHeight;
float compressionQuality = 0.5;//50 percent compression
if (actualHeight > maxHeight || actualWidth > maxWidth) {
@0oneo
0oneo / UIScrollView with masonry
Last active October 12, 2017 12:38
vertical and Horizontal scrollview using masonry
@interface ViewController ()
@property (strong, nonatomic) UIScrollView* vScrollView;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
@0oneo
0oneo / wwdc download url
Created June 7, 2014 15:27
获取wwdc session中的视频的下载链接
import re
import urllib2
s = urllib2.urlopen("https://developer.apple.com/videos/wwdc/2014/").read()
match = re.findall(r'http://devstreaming.apple.com/[\w/\d\.-]+hd[\w/\d\.]+mov\?dl=1', s)
print '\n'.join(match)
@0oneo
0oneo / changeExtension
Created May 25, 2014 07:59
change file name extension in batch
#!/bin/bash
directoryName="$1"
extension="$2"
regex='.+'
if ! [[ $extension =~ $regex ]]; then
echo "Usage: changeExtension directory newExtension";
exit 1;
fi
/*
* armv7sconvert <infile> <outfile>
* Switches CPU subsystem type to armv7s
*
* By Matt Galloway - http://www.galloway.me.uk/2012/09/hacking-up-an-armv7s-library/
*
* Based on g3spot.c from http://redbutton.sourceforge.net (c) Simon Kilvington, 2009
*/
#include <stdio.h>