Skip to content

Instantly share code, notes, and snippets.

@kukat
kukat / xcode.rb
Last active September 13, 2016 07:18 — forked from derencius/xcode.rb
aria2 downloader
require 'rubygems'
require 'mechanize'
if ARGV.size < 3
puts %q{Usage: ruby xcode.rb USERNAME PASSWORD "DOWNLOAD_URL" [WGET_PARAMS]}
puts %q{Example: ruby xcode.rb myusername@apple.com 123456 "https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_4_and_ios_sdk_4.3__final/xcode_4_and_ios_sdk_4.3__final.dmg" }
exit
end
a = Mechanize.new { |agent|
@bacella
bacella / button.m
Created January 26, 2014 05:09
Movable Button on iOS
- (void)viewDidLoad
{
[super viewDidLoad];
self.btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
self.btn.frame = CGRectMake(10, 10, 50, 50);
[self.btn setTitle:@"Touch" forState:UIControlStateNormal];
[self.btn addTarget:self action:@selector(dragMoving:withEvent:) forControlEvents:UIControlEventTouchDragInside];
[self.btn addTarget:self action:@selector(dragEnded:withEvent:) forControlEvents:UIControlEventTouchUpInside | UIControlEventTouchUpOutside];
[self.view addSubview:self.btn];
@hfossli-agens
hfossli-agens / gist:4676773
Created January 30, 2013 20:45
dispatch_after with repeat / loop
static void dispatch_repeated_internal(dispatch_time_t firstPopTime, double intervalInSeconds, dispatch_queue_t queue, void(^work)(BOOL *stop))
{
__block BOOL shouldStop = NO;
dispatch_time_t nextPopTime = dispatch_time(firstPopTime, (int64_t)(intervalInSeconds * NSEC_PER_SEC));
dispatch_after(nextPopTime, queue, ^{
work(&shouldStop);
if(!shouldStop)
{
dispatch_repeated_internal(nextPopTime, intervalInSeconds, queue, work);
}
@128keaton
128keaton / DestinationView.swift
Last active June 6, 2018 14:02
Dragging view in Swift 3
import Foundation
import Cocoa
class DestinationView: NSView {
var isHighlighed: Bool! = false
override func awakeFromNib() {
self.register(forDraggedTypes: [NSFilenamesPboardType])
}
func isHighlighted() -> Bool! {
@paztek
paztek / AppDelegate.m
Last active June 11, 2019 20:54
Allows videos to rotate in landscape when displayed in a portrait only iOS app
#import "AppDelegate.h"
#import <MediaPlayer/MediaPlayer.h>
@implementation AppDelegate
{
BOOL _isFullScreen;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
This file has been truncated, but you can view the full file.
//
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard.
//
#pragma mark Blocks
typedef void (^CDUnknownBlockType)(void); // return type and parameters are unknown
@lwr
lwr / autopac.sh
Last active February 13, 2020 07:35
使用 https://github.com/clowwindy/gfwlist2pac 生成自定义 PAC 的辅助脚本
#!/bin/bash
GFWLIST=https://autoproxy-gfwlist.googlecode.com/svn/trunk/gfwlist.txt
PROXY=127.0.0.1:7070
cd `dirname "${BASH_SOURCE[0]}"`
echo "Downloading gfwlist from $GFWLIST"
curl "$GFWLIST" --socks5-hostname "$PROXY" > /tmp/gfwlist.txt
/usr/local/bin/gfwlist2pac \
--input /tmp/gfwlist.txt \
@samrocketman
samrocketman / osx_wine_fallout3.md
Last active April 13, 2020 17:03
Fallout 3 Mac OS X on WINE. STALKER Call of Pripyat Mac OS X on WINE.

Windows-only games on Mac OS X

Achieved with WINE. None of the online tutorials were sufficient so I created this.

Games and settings

I've played the following Windows-only games with zero performance issues.

  • Fallout 3 GOTY Edition
  • S.T.A.L.K.E.R.: Call of Pripyat
@implementation UIImage (ResourceProxyHack)
+ (UIImage *)_iconForResourceProxy:(id)proxy format:(int)format {
// HACK: proxy seems garbage so we always show PDF for now.
let cgImage = [_bridge imageForFileType:@"pdf"];
// HACK: We use mainScreen here but could have multiple screens.
let image = [UIImage imageWithCGImage:cgImage scale:UIScreen.mainScreen.scale orientation:UIImageOrientationUp];
return image;
}
@elktros
elktros / Raspberry_Pi_Stepper_Motor_L298N.py
Created February 16, 2018 05:49
Python Script for Controlling a 12V Bipolar Stepper Motor with Raspberry Pi and L298N Motor Driver Module.
import RPi.GPIO as GPIO
import time
out1 = 13
out2 = 11
out3 = 15
out4 = 12
i=0
positive=0