Skip to content

Instantly share code, notes, and snippets.

View elkraneo's full-sized avatar
🎯
Focusing

Cristian Díaz elkraneo

🎯
Focusing
View GitHub Profile
@elkraneo
elkraneo / gist:9070046
Last active July 27, 2016 07:54
UIAlertView with RAC signal block
- (void)askListName {
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"List Name"
message:@"Desired Name for your new List?"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Create", nil];
[alertView setAlertViewStyle:UIAlertViewStylePlainTextInput];
[alertView.rac_buttonClickedSignal subscribeNext:^(NSNumber *buttonIndex) {
if ([buttonIndex isEqual:@1]) {
[[MWGListsManager sharedInstance] addListWithName:[[alertView textFieldAtIndex:0] text]];
@elkraneo
elkraneo / gist:bb74a66f02fb3493a458
Last active August 29, 2015 14:08
SK Particle Emitter
- (void)emitParticle:(SKScene *)whichScene {
NSString *emitterPath = [[NSBundle mainBundle] pathForResource:@"YourParticleFileName" ofType:@"sks"];
SKEmitterNode *particle = [NSKeyedUnarchiver unarchiveObjectWithFile:emitterPath];
particle.position = self.position;
particle.name = @"particleName";
particle.targetNode = self.scene;
[yourScene addChild:particle];
}
@elkraneo
elkraneo / gist:15b07b70ab11b3ad248e
Created May 26, 2015 15:20
Overriding Properties
class Vehicle {
var currentSpeed = 0.0
var description: String {
return "traveling at \(currentSpeed) miles per hour"
}
func makeNoise() {
// do nothing - an arbitrary vehicle doesn't necessarily make a noise
}
}
- (instancetype)initWithTitle:(NSString *)title iconBadgeNumber:(int)number iconBadgeColor:(UIColor *)backgroundColor iconBadgeTextColor:(UIColor *)textColor action:(actionBasicBlock)action
{
self = [[[NSBundle mainBundle] loadNibNamed:@"QBasicTableViewCell" owner:self options:nil] objectAtIndex:0];
if (self) {
//le code
}
return self;
}
let json = try JSON(data: response)
let movies: [Movie]?
switch json {
case let .array(jsonModels):
let moviesDict = try jsonModels.map { try JSON($0.getDictionary(at: "movie")) }
movies = try moviesDict.map(Movie.init)
default:
movies = nil
}
Makefile.binfile:18: recipe for target 'STM32F769I_Chris_out/DEBUG/application_int.bin' failed
make[1]: o:/CRCTool/emb_crc.exe: Command not found
make[1]: *** [STM32F769I_Chris_out/DEBUG/application_int.bin] Error 127
make[1]: *** Waiting for unfinished jobs....
(CRCTOOL) STM32F769I_Chris_out/DEBUG/application_ext.bin
make[1]: o:/CRCTool/emb_crc.exe: Command not found
Makefile.binfile:28: recipe for target 'STM32F769I_Chris_out/DEBUG/application_ext.bin' failed
make[1]: *** [STM32F769I_Chris_out/DEBUG/application_ext.bin] Error 127
make: *** [bin] Error 2
Makefile:58: recipe for target 'bin' failed
@elkraneo
elkraneo / noise.glsl
Created May 19, 2019 16:49
Gradient Noise by Inigo Quilez - iq/2013 https://www.shadertoy.com/view/XdXGW8
float noise(vec2 st) {
vec2 i = floor(st);
vec2 f = fract(st);
vec2 u = f * f * (3.0 - 2.0 * f);
return mix( mix( dot( random2(i + vec2(0.0, 0.0) ), f - vec2(0.0, 0.0) ),
dot( random2(i + vec2(1.0, 0.0) ), f - vec2(1.0, 0.0) ), u.x),
mix( dot( random2(i + vec2(0.0, 1.0) ), f - vec2(0.0, 1.0) ),
dot( random2(i + vec2(1.0, 1.0) ), f - vec2(1.0, 1.0) ), u.x), u.y);
@elkraneo
elkraneo / cellular2x2.glsl
Created May 19, 2019 20:30
Cellular noise ("Worley noise") in 2D in GLSL. Copyright (c) Stefan Gustavson 2011-04-19. All rights reserved. This code is released under the conditions of the MIT license. See LICENSE file for details.
// Permutation polynomial: (34x^2 + x) mod 289
vec4 permute(vec4 x) {
return mod((34.0 * x + 1.0) * x, 289.0);
}
// Cellular noise, returning F1 and F2 in a vec2.
// Speeded up by using 2x2 search window instead of 3x3,
// at the expense of some strong pattern artifacts.
// F2 is often wrong and has sharp discontinuities.
// If you need a smooth F2, use the slower 3x3 version.
@elkraneo
elkraneo / Distance Field Shapes.glsl
Created May 21, 2019 17:20
Author @kynd - 2016 Title: Distance Field Shapes http://www.kynd.info
float circle(vec2 p, float radius) {
return length(p) - radius;
}
float rect(vec2 p, vec2 size) {
vec2 d = abs(p) - size;
return min(max(d.x, d.y), 0.0) + length(max(d, 0.0));
}
float roundRect(vec2 p, vec2 size, float radius) {
/*
%1$@ = city
%2$@ = temperature
%3$@ = perceived
%4$@ = probability
%5$@ = amount
%6$@ = speed
%7$@ = duration
*/
"now.cast %@ %@ %@ %@ %@ %@ %@" = "Current temperature in %1$@: %2$@ which feels like %3$@ with %4$@ of rain probability and %5$@ of amount. Wind speeds up to %6$@ and %7$@ of sun duration.";