Skip to content

Instantly share code, notes, and snippets.

View parzibyte's full-sized avatar
💻
Coding

Parzibyte parzibyte

💻
Coding
View GitHub Profile
@zentala
zentala / formatBytes.js
Created September 27, 2017 11:57
Convert size in bytes to human readable format (JavaScript)
function formatBytes(bytes,decimals) {
if(bytes == 0) return '0 Bytes';
var k = 1024,
dm = decimals || 2,
sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
}
// Usage:
@shakee93
shakee93 / .htaccess
Created January 31, 2017 17:45
Laravel Apache hide .env and several security settings via .htaccess
# Disable Directory listing
Options -Indexes
# block files which needs to be hidden // in here specify .example extension of the file
<Files ~ "\.(env|json|config.js|md|gitignore|gitattributes|lock)$">
Order allow,deny
Deny from all
</Files>
# in here specify full file name sperator '|'
@BrianLian
BrianLian / angular_uibModal_resolve and_resuts_example.coffee
Created August 5, 2016 07:27
angular uibModal resolve and resuts example
$scope.edit=(who,index)->
modalInstance = $uibModal.open
templateUrl: 'editModal'
resolve :
scheduleType : -> $scope.scheduleType
devices : ->$scope.devices
controller: [ '$scope', '$uibModalInstance', 'scheduleType', 'devices', ($scope, $uibModalInstance, scheduleType, devices)->
$scope.scheduleType = scheduleType
$scope.devices = devices
$scope.ui = {}
@alfchee
alfchee / NumeroALetras.js
Last active May 3, 2024 20:12
Código en JavaScript que convierte números a letras, bastante útil para formularios de documentos contables y similares
/*************************************************************/
// NumeroALetras
// The MIT License (MIT)
//
// Copyright (c) 2015 Luis Alfredo Chee
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
@josephspurrier
josephspurrier / drop_encrypt.go
Last active March 24, 2020 17:48
Golang - Drag and Drop AES Encryption and Decryption
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"fmt"
"io"
"io/ioutil"
"os"
@pererinha
pererinha / ignoreMouseWheel.js
Created June 30, 2014 12:58
Angular JS Directive - to disable mouse wheel on input type number
directive( 'ignoreMouseWheel', function( $rootScope ) {
return {
restrict: 'A',
link: function( scope, element, attrs ){
element.bind('mousewheel', function ( event ) {
element.blur();
} );
}
}
} );
@BobNisco
BobNisco / controller.js
Last active February 27, 2023 15:43
onLongPress AngularJS Directive - Great for mobile!
// Somewhere in your controllers for this given example
// Example functions
$scope.itemOnLongPress = function(id) {
console.log('Long press');
}
$scope.itemOnTouchEnd = function(id) {
console.log('Touch end');
}
@iainconnor
iainconnor / Android Studio .gitignore
Created January 24, 2014 20:20
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
@apisurfer
apisurfer / bf.php
Created June 25, 2013 15:06
Simple brute force or string matching in PHP
<?php
/**
This is a simple proof of concept of a brute force algorithm for string matching with
given set of characters.
The way this works is that the algorithm counts from first to last possible combination of
given characters. Instead of counting(incrementing) in number base 10 we use
a new base which is derived from your set of possible characters (we count in symbols).
So if your characters list contains 27 characters the program actually counts in a 27 base
number system.
@joshdholtz
joshdholtz / SomeFragment.java
Last active December 22, 2022 09:41
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);