Skip to content

Instantly share code, notes, and snippets.

View Sanix-Darker's full-sized avatar
🐼
coding in the dark...

darker Sanix-Darker

🐼
coding in the dark...
View GitHub Profile
@Sanix-Darker
Sanix-Darker / [PHP] Force a download of a file
Last active September 23, 2017 20:47
[PHP] Force a download of a file
<?php
if(isset($_REQUEST['src'])){
$file_name = $_REQUEST['src'];
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename=\"".$file_name."\"");
readfile('../Your_Path_Here/'.$file_name);
exit;
}
?>
@Sanix-Darker
Sanix-Darker / [JS] Using the core $.ajax() method
Last active September 23, 2017 20:49
[JS] Using the core $.ajax() method
// Using the core $.ajax() method
$.ajax({
// The URL for the request
url: "post.php",
// The data to send (will be converted to a query string)
data: {
id: 123
},
// Whether this is a POST or GET request
type: "GET",
@Sanix-Darker
Sanix-Darker / [HTML][JS] Accept only number in input type text
Created October 3, 2017 09:01
[HTML][JS] Accept only number in input type text
<input type="text" class="form-control" onkeypress="return isNumber(event)">
<script>
function isNumber(evt) {
evt = (evt) ? evt : window.event;
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
return false;
}
return true;
}
@Sanix-Darker
Sanix-Darker / [HTML5][CSS3] Nice transform Scale
Created October 7, 2017 10:02
[HTML5][CSS3] Nice transform Scale
<link href='https://fonts.googleapis.com/css?family=Roboto:100,400,300,500,700' rel='stylesheet' type='text/css'>
<div align="center" class="fond">
<div style="width:1000px;">
<div class="style_prevu_kit" style="background-color:#cb2025;"></div>
<div class="style_prevu_kit" style="background-color:#f8b334;"></div>
<div class="style_prevu_kit" style="background-color:#97bf0d;"></div>
<div class="style_prevu_kit" style="background-color:#00a096;"></div>
<div class="style_prevu_kit" style="background-color:#93a6a8;"></div>
@Sanix-Darker
Sanix-Darker / [Ruby] Check if a gem is installed
Created October 11, 2017 15:03
[Ruby] Check if a gem is installed
#Check if a gem is installed
gem list -i "^gem_name$"
@Sanix-Darker
Sanix-Darker / [Ruby] CHeck the version of the ActiveRecord
Created October 11, 2017 15:04
[Ruby] CHeck the version of the ActiveRecord
# CHeck the version of the ActiveRecord
bundle show activerecord
@Sanix-Darker
Sanix-Darker / [JS] XmlhttpRequest
Created October 5, 2017 16:14
[JS] XmlhttpRequest
function onProgress(event) {
if (event.lengthComputable) {
var percentComplete = (event.loaded / event.total)*100;
console.log("Envoi en cours: %d%%", percentComplete);
} else {
// Impossible de calculer la progression puisque la taille totale est inconnue
}
}
@Sanix-Darker
Sanix-Darker / [CLI] Usefull Ionic commands
Last active November 3, 2017 09:40
[CLI] Usefull Ionic commands
# Hello H.I, there is a few list of basics command to learn when you start with ionic Framework
#There is the website for starter in IONIC: https://ionicframework.com/getting-started
#Fisrt install npm with nodeJS
#Install Cordova
npm install -g cordova
#Install the ionic Framework, i prefer most the IOnic 3
@Sanix-Darker
Sanix-Darker / [SHELL] Helpfull rails commands
Created October 19, 2017 07:40
[SHELL] Helpfull rails commands
#basics:
rails console
rails server
rake
rails generate
rails dbconsole
rails new app_name
#create scaffold
rails generate scaffold level
@Sanix-Darker
Sanix-Darker / [JS] Print an element from browser
Last active November 14, 2017 16:20
[JS] Print an element from browser
<div id="elementToprint">
Text to be in the PDF, simple function create by Sanix darker!!!
</div>
<input type="button" value="IMPRIME" onclick="PrintElem('elementToprint');">
<script type="text/javascript">
function PrintElem(elem)
{
var mywindow = window.open('', 'PRINT', 'height=400,width=600');