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
dispatch_queue_t myQueue = dispatch_queue_create("my queue",NULL);
//...
//...
//...
dispatch_async(imageQueue, ^{
// This will run the method in a separate thread
[self doSomeLongRunningTask];
});
NSThread *thread = [[NSThread alloc] initWithTarget:self
selector:@selector(run:)
object:nil];
[thread start];
//...
//...
- (void) run: (id) object{
NSLog(@"I'm running in another thread :D");
}
final String username = "[email protected]";
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,
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;
}
@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);
#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 / 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>
@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
- (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];
}
- (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"];