Skip to content

Instantly share code, notes, and snippets.

View phynet's full-sized avatar
🤘
I said yeah.

Sofia Swidarowicz phynet

🤘
I said yeah.
View GitHub Profile
struct MyConstraint {
static func changeMultiplier(constraint: NSLayoutConstraint, multiplier: CGFloat) -> NSLayoutConstraint {
let newConstraint = NSLayoutConstraint(
item: constraint.firstItem,
attribute: constraint.firstAttribute,
relatedBy: constraint.relation,
toItem: constraint.secondItem,
attribute: constraint.secondAttribute,
multiplier: multiplier,
constant: constraint.constant)
/*
* Example: needed to save a pdf document and show that pdf data in main thread. So using the example:
*/
dispatch_async(dispatch_get_global_queue(0, 0), ^{
//load your data here.
dispatch_async(dispatch_get_main_queue(), ^{
//update UI in main thread.
});
});
@phynet
phynet / XCTAsserts.md
Created February 19, 2016 08:27
List of all XCTAssert Macros found in Xcode

##List of All XCT ASSERT macros used to test in XCODE

  XCTFail(...)
      _XCTPrimitiveFail(self, __VA_ARGS__)
  
  XCTAssertNil(expression, ...) 
      _XCTPrimitiveAssertNil(self, expression, @#expression, __VA_ARGS__)
  
  XCTAssertNotNil(expression, ...) 

_XCTPrimitiveAssertNotNil(self, expression, @#expression, VA_ARGS)

{
"cordova": [
[
"plugin",
"add",
"https://descinet.bbva.es/stash/scm/cellsnative/cordova-plugin-deviceinfo.git",
"https://descinet.bbva.es/stash/scm/cellsnative/cordova-plugin-base.git",
"https://descinet.bbva.es/stash/scm/cellsnative/cordova-plugin-html5video.git",
"https://descinet.bbva.es/stash/scm/cellsnative/cordova-plugin-touchid.git",
"https://descinet.bbva.es/stash/scm/cellsnative/cordova-plugin-nativeheader",
'use strict';
var gulp = require('gulp');
var cordova = require('gulp-cordova');
gulp.task('cordova:init', function() {
gulp.src('./package.json')
.pipe(cordova())
})
@phynet
phynet / exec-cordova.js
Created February 17, 2016 08:05
Script to compile cordova project (need a packgae.json and a gulp file)
var path = require('path');
var exec = require('child_process').exec;
var spawn = require('child_process').spawn;
var versioniOS = '@4.0.1';
var versionAndroid = '@5.0.0';
function logError(messageError, messageSpinner){
console.log(messageError);
cli.spinner(messageSpinner, true);
@phynet
phynet / install-cl-js.js
Last active July 18, 2016 19:28
Using node to install something using command line
//Using npm command packgae
var npm = require('npm');
npm.load(function(err) {
npm.commands.install(['ffi'], function(er, data) {
// log errors or data
});
npm.on('log', function(message) {
console.log(message);
});
});
@phynet
phynet / install-node-package-cordova.js
Last active February 8, 2016 08:19
How to install a CL in a node-JS cordova plugin? you may ask. I did the same question. Here it is.
module.exports = function(ctx) {
console.log('Installing npm packgae replace');
var Q = ctx.requireCordovaModule('q');
var deferral = new Q.defer();
var exec = require('child_process').exec;
var child = exec('npm install replace', function(error,stdout,stderr){
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
@phynet
phynet / upload-photo-parse.js
Created February 4, 2016 08:35
This was a JS - HTML that I found in the interwebs and changed it to fit my needs, when Parse was alive did work. RIP.
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<form id='fileupload' name='fileupload' enctype='multipart/form-data' method='post'>
<fieldset>
<input type='file' name='fileselect' id='fileselect'></input>
<input id='uploadbutton' type='button' value='Upload to Parse'/></br></br>
File URL <input type='text' id='resultURL' size='155'></input>
</fieldset>
</form>
@phynet
phynet / cordova-hook-run-script-xcode-for-crashlytics.js
Last active February 4, 2016 15:49
This is a JS-Node Hook Plugin for Cordova, that adds the "Run Script" option in XCODE for CRASHLYTICS. What it does, is to add the PBXBuildFile section in project.pbxproj file. Thanks to my lovely bf for pointing me out to use the global match (g modifier) in the regex part
/**
- Really important: install first npm package 'replace'.
*/
module.exports = function(ctx) {
var apiKey = 'YourApiKey';
var secretKey = 'YourSecretKey';
var shellScript = '\".\/Fabric.framework\/run '+ apiKey + ' '+ secretKey+'\"';
//If you are having troubles with Fabric's path, try to point to where the Fabric.framework is added in your project.