vendredi 11 septembre 2015

Fixed topcontainer makes everything fixed

I am trying to make a website with a topcontainer with fixed position, giving id position:fixed; in CSS. However, this makes the following class fixed aswell even though I use postion:relative;. Can somebody please help me?

The HTML:

<!DOCTYPE HTML>
<html>
</html>
<body>
<link rel="stylesheet" href="../../css/style_four_sprint.css"/>


<script type="text/javascript">

    function selected_four_sprint(val){
    if (val == "next"){
        document.write(5 + 6)

        }

}
 </script>
<head>
<title>Hello Wolrd</title>
</head>

    <div class="top_container"> 
    <div class="top_container"> 
    <img id="loggo" src="../../images/logo_top_small.png"/>

    <div id="toolname">Love to all!</div>   

    <div class="select">
        <table>
            <tr>
                <td>What do you want?</td>
                <td>
                    <select id="four_sprint_select" onchange="selected_four_sprint(value);">
                        <option>Select</option>
                        <option value="next">Next</option>
                </td>
            </tr>
        <table>
    </div>
</div>
<div class="teams_container">
  <div id="no_team"> No team </div>
  <div id="bamse"> Bamse </div>
  <div id="skalman"> Skalman </div>
</div>

</body>

The css:

body, html {
padding:0;
width:100%;
margin:0;
height:2000px;
z-index:1;
background:white;
font-family:'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;     
}

.top_container{
top:3px;
left:0px;
position:fixed;
height:43px;
width:100%;
border-bottom:1px solid #bcbaba;
z-index:15000;
background: #ffffff; /* Old browsers */
background: -moz-linear-gradient(top,  #ffffff 0%, #e5e5e5 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#e5e5e5)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  #ffffff 0%,#e5e5e5 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  #ffffff 0%,#e5e5e5 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  #ffffff 0%,#e5e5e5 100%); /* IE10+ */
background: linear-gradient(to bottom,  #ffffff 0%,#e5e5e5 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#e5e5e5',GradientType=0 ); /* IE6-9 */
}

#toolname{
color:black;
float:left;
padding-right:20px;
position:relative;
margin-left:10px;
font-family:'Ericsson Capital TT';
z-index:2000;
font-size:15px;
margin-top:7px;
line-height:30px;
height:30px;
border-right:1px solid #DEDEDE;
/* border-bottom:1px solid #bcbaba;  */
}

#loggo{
margin-top:8px;
margin-left:8px;
float:left;
}

.select{
margin-left:10px;
float:left;
font-size:14px;
height:30px;
line-height:30px;
margin-top:5px;
border-right:1px solid #DEDEDE;
padding-right:10px;
}

.teams_container{
width:100%;
background-color:#55555;
padding-top:35px;   
position:relative;
right:200px;
font-size:25px;
}



via Chebli Mohamed

How to close the setting screen in android programmatically

I need close the settings screen from another app, how to works appLock.

here:

http://ift.tt/1EKZZaT

my service code, this code works OK

final ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    Timer timer = new Timer();
    timer.scheduleAtFixedRate(
            new TimerTask() {
                public void run() {
                    String appProcesses = activityManager.getRunningTasks(1).get(0).topActivity.getPackageName();

                    if (appProcesses.equals("com.android.settings")) {
                        Intent i1=new Intent(service.this, LockedScreen.class);
                        i1.setAction(Intent.ACTION_MAIN);
                        i1.addCategory(Intent.CATEGORY_HOME);
                        i1.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                        i1.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                        i1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                        startActivity(i1);

                    }
                }
            }
            , 0, 1000);

my lock screen code in backpresed and this code don't close settings activity:

 @Override
public void onBackPressed() {
    super.onBackPressed();
    try {
        ActivityManager am = (ActivityManager) getApplicationContext().getSystemService("Settings");
        Method forceStopPackage;
        forceStopPackage = am.getClass().getDeclaredMethod("forceStopPackage", String.class);
        forceStopPackage.setAccessible(true);
        forceStopPackage.invoke(am, "com.android.settings");
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}

error in backpressed, this error is in forceStopPackage = am.getClass().getDeclaredMethod("forceStopPackage", String.class);:

09-11 09:35:21.315    3037-3037/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NullPointerException
        at pe.com.oscar.settingsintent.LockedScreen.onBackPressed(LockedScreen.java:41)
        at android.app.Activity.onKeyUp(Activity.java:2361)
        at android.view.KeyEvent.dispatch(KeyEvent.java:2707)
        at android.app.Activity.dispatchKeyEvent(Activity.java:2594)
        at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2098)
        at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:3608)
        at android.view.ViewRootImpl.handleImeFinishedEvent(ViewRootImpl.java:3578)
        at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:2828)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:153)
        at android.app.ActivityThread.main(ActivityThread.java:5071)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
        at dalvik.system.NativeStart.main(Native Method)

HELPP PLEASE!!



via Chebli Mohamed

how unreferred values from string pool get remove?

I'm curious, how values from string-pool get removed?

suppose:

String a = "ABC"; // has reference of string-pool
String b = new String("ABC"); // has heap reference

b = null;
a= null;

In case of GC, "ABC" from heap get collected.But "ABC" still there in pool(because its in permGen and GC would not effect it).

if we keep adding values like

String c = "ABC"; // pointing to 'ABC' in pool. 

    for(int i=0; i< 10000; i++) {
      c = ""+i; // each iteration add new value in pool. and pervious values has no pointer  

    } 

I want to know, will pool remove unreferred values? if not, it's mean pool eating up unnecessary memory. than what's a point, jvm is using pool? when it could be a performance risk?



via Chebli Mohamed

IOS Developing:Tab Bar Item's Image Display a Blue Square

The bar item images I prepared are about 35*35 and I use the Sketch to export the [1x & 2x] size images; (I can't insert any images for instances at here because of my zero reputation//Sorry about this!)

Then it displays a blue square :<

the function and title of Item is OK

BUT just the icons are wrong

Could someone tells me how to fix it! Appreciate!!!



via Chebli Mohamed

Setting up a Ground node using SpriteKit?

I've been designing a game where I want the game to stop as soon as the ball makes contact with the ground. My function below is intended to set up the ground.

class GameScene: SKScene, SKPhysicsContactDelegate {

 var ground = SKNode() 

 let groundCategory: UInt32 = 0x1 << 0
 let ballCategory: UInt32 = 0x1 << 1

 func setUpGround() -> Void {
        self.ground.position = CGPointMake(0, self.frame.size.height)
        self.ground.physicsBody = SKPhysicsBody(rectangleOfSize: CGSizeMake(self.frame.size.width, self.frame.size.height)) //Experiment with this
        self.ground.physicsBody?.dynamic = false

        self.ground.physicsBody?.categoryBitMask = groundCategory    //Assigns the bit mask category for ground
        self.ball.physicsBody?.contactTestBitMask = ballCategory  //Assigns the contacts that we care about for the ground

        self.addChild(self.ground)
    } 
}

The problem I am noticing is that when I run the iOS Simulator, the Ground node is not being detected. What am I doing wrong in this case?



via Chebli Mohamed

How can I connect to a MySQL database with passwords and usernames in Swift

Is it possible to connect to a MySQL from Swift with out having a .php script echoing JSON? I want to use it for passwords etc. So I can't have it visible for every one else.



via Chebli Mohamed

How to set React to production mode when running behind a python webserver

I need to run React in production mode, which presumably entails defining the following somewhere in the enviornment:

process.env.NODE_ENV = 'production';

The issue is that I'm running this behind Tornado (a python web-server), not Node.js. I also use Supervisord to manage the tornado instances, so it's not abundantly clear how to set this in the running environment.

I do however use Gulp to build my jsx files to javascript.

Is it possible to somehow set this inside Gulp? And if so, how do I check that React is running in production mode?

Here is my Gulpfile.js:

'use strict';

var gulp = require('gulp'),
        babelify = require('babelify'),
        browserify = require('browserify'),
        browserSync = require('browser-sync'),
        source = require('vinyl-source-stream'),
        uglify = require('gulp-uglify'),
        buffer = require('vinyl-buffer');

var vendors = [
    'react',
    'react-bootstrap',
    'jquery',
];

gulp.task('vendors', function () {
        var stream = browserify({
                        debug: false,
                        require: vendors
                });

        stream.bundle()
                    .pipe(source('vendors.min.js'))
                    .pipe(buffer())
                    .pipe(uglify())
                    .pipe(gulp.dest('build/js'));

        return stream;
});

gulp.task('app', function () {
        var stream = browserify({
                        entries: ['./app/app.jsx'],
                        transform: [babelify],
                        debug: false,
                        extensions: ['.jsx'],
                        fullPaths: false
                });

        vendors.forEach(function(vendor) {
                stream.external(vendor);
        });

        return stream.bundle()
                                 .pipe(source('build.min.js'))
                                 .pipe(buffer())
                                 .pipe(uglify())
                                 .pipe(gulp.dest('build/js'));

});

gulp.task('watch', [], function () {
    // gulp.watch(['./app/**/*.jsx'], ['app', browserSync.reload]);
    gulp.watch(['./app/**/*.jsx'], ['app']);
});

gulp.task('browsersync',['vendors','app'], function () {
        browserSync({
            server: {
                baseDir: './',
            },
            notify: false,
            browser: ["google chrome"]
    });
});

gulp.task('default',['browsersync','watch'], function() {});



via Chebli Mohamed