Skip to content

Instantly share code, notes, and snippets.

View DmitrySeredinov's full-sized avatar

Dmitry Seredinov DmitrySeredinov

View GitHub Profile
#!/bin/sh
PLIST_BUDDY=/usr/libexec/PlistBuddy
function add_compatibility() {
"$PLIST_BUDDY" -c "Add DVTPlugInCompatibilityUUIDs:10 string $2" \
"$1/Contents/Info.plist"
}
function has_compatibility() {
#import <Foundation/Foundation.h>
@interface JNWThrottledBlock : NSObject
// Runs the block after the buffer time _only_ if another call with the same identifier is not received
// within the buffer time. If a new call is received within that time period the buffer will be reset.
// The block will be run on the main queue.
//
// Identifier and block must not be nil.
+ (void)runBlock:(void (^)())block withIdentifier:(NSString *)identifier throttle:(CFTimeInterval)bufferTime;

##Creating a timer with Grand Central Dispatch

At the following is the implementation file of a sample class that shows, how to make a timer with the help of Grand Central Dispatch. The timer fires on a global queue, just change the queue to the main queue or any custom queue and the timer fires on this queue and not on the global queue anymore.

#import <Foundation/Foundation.h>

@interface SampleClass : NSObject
- (void)startTimer;
@DmitrySeredinov
DmitrySeredinov / IoC.md
Last active August 29, 2015 14:23 — forked from greabock/IoC.md

Инверсия управления (англ. Inversion of Control, IoC) — важный принцип объектно-ориентированного программирования, используемый для уменьшения зацепления в компьютерных программах. Также архитектурное решение интеграции, упрощающее расширение возможностей системы, при котором контроль над потоком управления программы остаётся за каркасом - ru.wikipedia.org


Сегодня хотелось бы поговорить о реализации инверсии управления в Laravel. Это один из самых важных аспектов организации слабой связанности компонентов в любимом нами фреймворке, и его понимание играет ключевую роль при создании качественных пакетов и приложений.

Когда мы говорим об IoC в Laravel, то следует знать, что он стоит на трех китах:

  1. Внедрение зависимостей (Dependency Injection)
@DmitrySeredinov
DmitrySeredinov / resize-mark.pl
Created December 22, 2011 12:21 — forked from shoorick/.gitignore
Image resizer and marker
#!/usr/bin/perl -w
use strict;
=head1 DESCRIPTION
Make small pictures from big ones.
=head1 USAGE
resize-mark.pl
#!/usr/bin/env ruby
# Aside from removing Ruby on Rails specific code this is taken verbatim from
# mislav's git-deploy (http://github.com/mislav/git-deploy) and it's awesome
# - Ryan Florence (http://ryanflorence.com)
#
# Install this hook to a remote repository with a working tree, when you push
# to it, this hook will reset the head so the files are updated
if ENV['GIT_DIR'] == '.'
@DmitrySeredinov
DmitrySeredinov / LICENSE.txt
Created January 30, 2012 22:05 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@DmitrySeredinov
DmitrySeredinov / httpauth.php
Created February 20, 2012 09:45 — forked from cambiata/httpauth.php
Basic Http Authentication
<?php
/**
* Attempt to wrap Http Authentication into a separate class...
*
* Ideas and some code from FuelPHP Controller_Rest
* https://github.com/fuel/fuel/blob/develop/fuel/core/classes/controller/rest.php
*
*/
@DmitrySeredinov
DmitrySeredinov / recipe-ios.sh
Created March 5, 2012 19:07 — forked from niklassaers/recipe-ios.sh
Compile protobuf 2.4.1 on iOS 5
export ARCH=arm-apple-darwin10
export ARCH_PREFIX=${ARCH}-
export PLATFORM=iPhoneOS
export SDKVER=5.0
export DEVROOT=/Developer/Platforms/${PLATFORM}.platform/Developer
export SDKROOT="$DEVROOT/SDKs/${PLATFORM}$SDKVER.sdk"
export PKG_CONFIG_PATH="$SDKROOT/usr/lib/pkgconfig:$DEVROOT/usr/lib/pkgconfig"
export AS="$DEVROOT/usr/bin/as"
export ASCPP="$DEVROOT/usr/bin/as"
@DmitrySeredinov
DmitrySeredinov / AndroidUtils.java
Created April 19, 2012 10:09 — forked from regisd/AndroidUtils.java
Intent to open the twitter client
public Intent findTwitterClient() {
final String[] twitterApps = {
// package // name - nb installs (thousands)
"com.twitter.android", // official - 10 000
"com.twidroid", // twidroyd - 5 000
"com.handmark.tweetcaster", // Tweecaster - 5 000
"com.thedeck.android" // TweetDeck - 5 000 };
Intent tweetIntent = new Intent();
tweetIntent.setType("text/plain");
final PackageManager packageManager = getPackageManager();