Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Chiheb Nabil chihebnabil

🏠
Working from home
Block or report user

Report or block chihebnabil

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View MainActivity.java
package nabil.monjeuquiz.com.calculator;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
View Hero.java
package net.simplifiedlearning.customlistviewandroid;
/**
* Created by Belal on 9/14/2017.
*/
public class Hero {
int image;
String name, team;
@chihebnabil
chihebnabil / paypal.js
Last active Jul 11, 2017
Paypal Fee Calculator
View paypal.js
// Paypal Fee Calculator
// default sum
var sum = 100;
// default rate
feeRate = 0.049;
// default fee
fee = sum * feeRate + 0.3
// to get sum you need to demand to your client sum2
var sum2 = (0.3 + sum) / (1 - feeRate)
@chihebnabil
chihebnabil / script.js
Last active Apr 10, 2017
javascript : flat array to tree
View script.js
var arr = [
{id: 1, title: 'hello', parent_id: 0},
{id: 2, title: 'hello', parent_id: 0},
{id: 3, title: 'hello', parent_id: 1},
{id: 4, title: 'hello', parent_id: 3},
{id: 5, title: 'hello', parent_id: 4},
{id: 6, title: 'hello', parent_id: 4},
{id: 7, title: 'hello', parent_id: 3},
{id: 8, title: 'hello', parent_id: 2}
];
View upload.php
<?php
$data['file'] = $_FILES;
$data['text'] = $_POST;
echo json_encode($data);
?>
View app.js
$(function () {
$('#my_form').on('submit', function (e) {
// prevent browser from submitting the form
e.preventDefault();
var $form = $(this);
var formdata = (window.FormData) ? new FormData($form[0]) : null;
var data = (formdata !== null) ? formdata : $form.serialize();
$.ajax({
View index.html
<form id="my_form" method="post" action="upload.php" enctype="multipart/form-data">
<input type="text" name="title">
<textarea name="content"></textarea>
<input type="file" name="image" accept="image/*">
<button type="submit">OK</button>
</form>
View app.js
$(function () {
$('#my_form').on('submit', function (e) {
// prevent browser from submitting the form
e.preventDefault();
var $form = $(this);
$.ajax({
url: $form.attr('action'),
type: $form.attr('method'),
@chihebnabil
chihebnabil / data.json
Last active Aug 27, 2016
Let's build a mobile application with Ionic Framework #2
View data.json
[
{
"Book":{
"id":"51",
"title":"Le Journal D\u2019une Femme De Chambre 01",
"preview":"\/mp3\/Octave_Mirbeau_-_Le_Journal_d_une_femme_de_chambre_Chap01.mp3",
"image":"\/sounds\/cover\/1\/51.webp",
"top":false,
"category_id":"16",
View upload.php
?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.
$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
You can’t perform that action at this time.