Skip to content

Instantly share code, notes, and snippets.

View onmotion's full-sized avatar
:octocat:

Alexandr Kozhevnikov onmotion

:octocat:
View GitHub Profile
@onmotion
onmotion / Yii2_joinWith_subquery.php
Created January 31, 2018 12:12
Yii2 joinWith subquery
<?php
$id = $this->badge_id;
return \common\models\Country::find()->joinWith(['badgeCountryAccess' => function($query) use ($id){
return $query->andOnCondition(['bca_badge_id' => $id]);
}])->orderBy('country_name')->all();
@onmotion
onmotion / ios keyboard auto scroll.swift
Last active February 5, 2018 12:23
ios keyboard auto scroll
var activeField: UITextField? = nil
func registerForKeyboardNotifications(){
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
}
func removeForKeyboardNotifications(){
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIKeyboardWillShow, object: nil)
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIKeyboardWillHide, object: nil)
@onmotion
onmotion / example.xml
Last active February 9, 2018 11:24
Xcode App Transport Security Exception Domains
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<false/>
<key>NSExceptionDomains</key>
<dict>
<key>cocoacasts.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
@onmotion
onmotion / git.md
Last active February 19, 2018 11:24
git remove all branches except master

remove all branches except master

git branch -a | grep -v "master" | sed -e 's/remotes\/origin\///g' | xargs git push origin --delete
@onmotion
onmotion / centering.swift
Created March 14, 2018 12:15
swift centering content inside scrollView
//centering content inside scrollView
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
let offsetY = max((scrollView.bounds.height - scrollView.contentSize.height) * 0.5, 0)
self.scrollView.contentInset = UIEdgeInsetsMake(offsetY, 0, 0, 0)
}
mount --bind /tmp/smbshare /jffs
nvram set sys_enable_jffs2=1
ipkg update failed for me, so I did a work-around:
mkdir -p /jffs/tmp/ipkg
ipkg update
ipkg list
@onmotion
onmotion / dd-wrt tcpdump
Created March 24, 2018 16:15
dd-wrt tcpdump
For anyone having this problem, try this to install it in RAM:
/bin/ipkg -d /tmp/root -force-depends install tcpdump
It still won't work from command prompt as usual, but you can run it like this if you have libpcap installed in jffs still:
@onmotion
onmotion / git remove all branches except master.sh
Created June 6, 2018 12:01
git remove all branches except master
#!/bin/bash
# local
git branch | grep -v "master" | xargs git branch -D
# remote
git branch -a --merged remotes/origin/master | grep -v master | grep "remotes/origin/" | cut -d "/" -f 3- | xargs -n 1 git push --delete origin
@onmotion
onmotion / remove all directories except.sh
Created August 14, 2018 10:36
remove all directories except
#!/bin/bash
find . ! -name 'thumbnails' -type d -maxdepth 1 -exec rm -rf {} +
@onmotion
onmotion / gist:258760396b4ec902eefe7f255bf7091c
Created October 11, 2018 07:34
webhook secret for packagist
{"repository":{"url":"https://packagist.org/packages/YOUR PACKAGE URL"}}