Skip to content

Instantly share code, notes, and snippets.

View bouchtaoui-dev's full-sized avatar

Nordin-010 bouchtaoui-dev

  • Netherlands, Rotterdam
View GitHub Profile
@bouchtaoui-dev
bouchtaoui-dev / Communicator.h
Created January 27, 2017 13:34 — forked from rjungemann/Communicator.h
How to open a TCP socket in Objective-C
#import <Foundation/Foundation.h>
@interface Communicator : NSObject <NSStreamDelegate> {
@public
NSString *host;
int port;
}
- (void)setup;
// Found this snippet at: https://gist.github.com/creationix/707146
// Load the TCP Library
net = require('net');
// Keep track of the chat clients
var clients = [];
// Start a TCP Server
- (void) runSpinAnimationOnView:(UIView*)view duration:(CGFloat)duration rotations:(CGFloat)rotations repeat:(float)repeat;
{
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 /* full rotation*/ * rotations * duration ];
rotationAnimation.duration = duration;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = repeat;
[view.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
- (void) startRotatingWithDuration: (double) duration {
NSString *animKey = @"rotation";
if([self.layer animationForKey: animKey] == nil) {
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath: @"transform.rotation"];
animation.duration = duration;
animation.repeatCount = INFINITY;
/*animation.fromValue = [NSNumber numberWithFloat: 0.0];*/
animation.toValue = [NSNumber numberWithFloat: 2*M_PI];
[self.layer addAnimation: animation forKey: animKey];
}
@bouchtaoui-dev
bouchtaoui-dev / Android Studio .gitignore
Created October 9, 2016 10:30 — forked from iainconnor/Android Studio .gitignore
A .gitignore for use in Android Studio
# Built application files
/*/build/
# Crashlytics configuations
com_crashlytics_export_strings.xml
# Local configuration file (sdk path, etc)
local.properties
# Gradle generated files
@bouchtaoui-dev
bouchtaoui-dev / styles.xml
Created May 6, 2016 13:29 — forked from jamesmontemagno/styles.xml
Transparent ActionBar
<!-- Application theme. -->
<style name="MyTheme" parent="@android:style/Theme.Holo">
<item name="android:windowActionBarOverlay">true</item>
<item name="android:actionBarStyle">@style/MyTheme.ActionBar</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@color/red_background</item>
</style>
<style name="MyTheme.ActionBar" parent="android:Widget.Holo.ActionBar">
<item name="android:background">@android:color/transparent</item>
<item name="android:backgroundStacked">@android:color/transparent</item>
#import <LocalAuthentication/LocalAuthentication.h>
/* A very simple way to scan your fingerprint... */
- (IBAction)didPressScan:(UIButton *)sender {
NSLog(@"Hallo...!");
LAContext *myContext = [[LAContext alloc] init];
NSError *authError = nil;
NSString *myLocalizedReasonString = @"Used for quick and secure access to the Remob app :P";
@bouchtaoui-dev
bouchtaoui-dev / SomeFragment.java
Created April 9, 2016 13:52 — forked from joshdholtz/SomeFragment.java
Android Google Maps V2 - MapView in XML
public class SomeFragment extends Fragment {
MapView mapView;
GoogleMap map;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.some_layout, container, false);
protected boolean isAvailable() {
if (getActivity() == null) return false;
if (getActivity().isFinishing()) return false;
if (!isAdded()) return false;
if (isDetached()) return false;
if (!isVisible()) return false;
return true;
}
final String username = "username@gmail.com";
final String password = "password";
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.port", "587");
Session session = Session.getInstance(props,