Skip to content

Instantly share code, notes, and snippets.

View vparihar01's full-sized avatar

Vivek Parihar vparihar01

View GitHub Profile
@vparihar01
vparihar01 / README.md
Last active November 11, 2016 15:09
Swift 2 + IOS >8.4 tips, tricks and code snippets for various UI's and functionality.

Swift 2 + IOS 8.4 & above Code Samples, tips, tricks for various UI customization

  • [UIViewExtension] - UIView extension for adding view border , corner radius , border color, border width and setting custom border like left,right,top and bottom borders from Storyboard.
  • [UILabelCustomize] - Add the shadow to UILabel. Customize the uilabel, to add the border with color, make it round and translate the inner text to right by X.
  • [UIColorHexToColor] - Convert the hex color into ios colors.
  • [UIbuttonExtension] - Text padding/inset from left to UIButton.
  • [buttonBorder] - IOS Add top , bottom, left and right button to button/text field.
  • [buttonPadding] - Add little text padding/inset from left
  • [StringExtension] - Truncate String in Swift
@vparihar01
vparihar01 / bash-tricks-find.sh
Last active December 3, 2015 06:07
Using Wildcards in bash for various file related task like list, rm.
# How To Use Find and Locate to Search for Files on a Linux
$ find -name "name_of_file_or_dir" #Finding by Name
$ find -iname "name_of_file_or_dir" #To find a file by name, but ignore the case of the name_of_file_or_dir
# Finding by Type
$ find -type type_descriptor query
#Some of the most common descriptors that you can use to specify the type of file are here:
#f: regular file
#d: directory
#l: symbolic link
@vparihar01
vparihar01 / fetchLink.js
Last active October 21, 2015 20:10
to fetch all id with simple regex and then prepare the new link.
@vparihar01
vparihar01 / daily_utility.sh
Last active May 24, 2022 08:16
Useful commands
1. pods spec edit podname |> pods spec edit opencv will open the podspecs.json file which we can edit to our needs. Like changing the download url of PODS.
2. history |> list all the command have been used in command line.
3. netstat -tulpn | grep fms |> list all processes running on the system with their PIDs.
4. To view the current transaction:
SELECT` `* ``FROM` `information_schema.innodb_trx \G
5. To view the currently locked transactions:
SELECT` `* ``FROM` `INFORMATION_SCHEMA.INNODB_LOCKS;
6. To view the transactions currently waiting for a lock:
SELECT` `* ``FROM` `INFORMATION_SCHEMA.INNODB_LOCK_WAITS;
@vparihar01
vparihar01 / getVideoUrl.js
Created August 9, 2015 22:00
to extract the video file if video is playing from the jwPlayer
var config = jwPlayer().config
var file = config.file
@vparihar01
vparihar01 / addEffect.swift
Created July 6, 2015 11:15
swift Blur, Vibrant and Vibrancy
// Blur Effect
var blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Dark)
var blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.frame = view.bounds
view.addSubview(blurEffectView)
// Vibrancy Effect
var vibrancyEffect = UIVibrancyEffect(forBlurEffect: blurEffect)
var vibrancyEffectView = UIVisualEffectView(effect: vibrancyEffect)
vibrancyEffectView.frame = view.bounds
@vparihar01
vparihar01 / importVideoToAppDir.swift
Created June 26, 2015 14:17
Importing video using the AVAssetExportSession session
Hey Isarathg this is classic use case of IOS devices. Which don't let you access any Photo Album assets directly using path value. To cross check my answer please just check FileExistsAtPath for your file like below -:
println(NSFileManager.defaultManager().fileExistsAtPath( urlvalue.path!))
O/P you will get => False
I also end up with this issue couple of days back After reading the whole IOS documentation. What I have figured it out "We can only access PhotoAlbum Assets if and only if we have PHImageManager session open". To cross check this statement please try below code -:
var currentVideofetch: PHFetchResult!
required init(coder aDecoder: NSCoder) {
class func requestOpeningMovies() {
let movies = [ XMCMovie(id: "0", title: "The Hobbit: The Battle Of The Five Armies", tomatometer: 62, consensus: "Suitably grim, epic, and action-packed, The Hobbit: The Battle of the Five Armies ends Peter Jackson's second Middle-earth trilogy on a rousing high note.", imageName: "hobbit"),
XMCMovie(id: "1", title: "Night At The Museum: Secret Of The Tomb", tomatometer: 53, consensus: "No consensus yet.", imageName: "museum"),
XMCMovie(id: "2", title: "Annie", tomatometer: 20, consensus: "The new-look Annie hints at a progressive take on a well-worn story, but smothers its likable cast under clichés, cloying cuteness, and a distasteful materialism.", imageName: "annie"),
XMCMovie(id: "3", title: "Mr. Turner", tomatometer: 97, consensus: "Led by a masterful performance from Timothy Spall and brilliantly directed by Mike Leigh, Mr. Turner is a superior Hollywood biopic.", imageName: "turner"),
XMCMov
@vparihar01
vparihar01 / purge.vcl
Last active August 29, 2015 14:14
varnish cache hack to purge all request url which are originated due to url's
if (req.method == "PURGE") {
if (!client.ip ~ purge) {
return(synth(405,"Not allowed."));
}
# Throw a synthetic page so the
# request won't go to the backend.
if (req.url ~ "(\/.*\?$)"){
ban("req.http.host == " + req.http.host + " && req.url ~ " + req.url + "\?(.*)?$");
}
@vparihar01
vparihar01 / sso_db_fields
Created February 2, 2015 16:38
SSO RubyCAS information we are going to store in dB. Fields
ID
first_name
last_name
username
email
hash_password
salt
creation_timestamp
update_timestamp
account_state