View dateTimeFilter.js
angular.module('date-time-filter') | |
.filter('dateTimeFilter', () => input => 'string' === typeof input ? input.replace(/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})Z$/, '$1 $2') : input); |
View camelCaseToCapitalized.js
(function(angular) { | |
// 'camelCaseName' | camelCaseToCapitalized => 'Camel Case Name' | |
var camelCaseToCapitalizedFilter = function() { | |
return function(string) { | |
return string | |
.replace(/([A-Z])/g, ' $1') | |
.replace(/^./, function(str) { | |
return str.toUpperCase(); | |
}); | |
}; |
View customValuesFilter.js
(function(angular) { | |
var addCustomValuesFilter = function () { | |
// string | addCustomValues : true : 1 : 2 | |
return function () { | |
var input = arguments[0], | |
shouldApplyFilter = arguments[1] !== false, | |
i, len, | |
values = [], | |
result = input; | |
if (shouldApplyFilter) { |
View auto_increment.sql
-- Get AUTO_INCREMENT current value: | |
SELECT `AUTO_INCREMENT` | |
FROM INFORMATION_SCHEMA.TABLES | |
WHERE TABLE_SCHEMA = 'DatabaseName' | |
AND TABLE_NAME = 'TableName'; | |
-- SET AUTO_INCREMENT value (this number will be user for NEXT inserted element): | |
ALTER TABLE `TableName` AUTO_INCREMENT = 5; |
View downloadWebsite.sh
wget -r --no-parent http://site.com/songs/ |
View fileModel.php
class File extends CActiveRecord | |
{ | |
public function rules() | |
{ | |
array('filename', 'file', 'types'=>'pdf, doc, docx, xls, xlsx, ods, odt, zip, rar, avi, mp4, flv, txt, webm', 'allowEmpty' => true), | |
); | |
} | |
/** | |
* Get file path by file name in database |
View inject_script.js
// Helper function to inject a <script> tag. | |
function injectScript(url, onload, onerror) { | |
var script = document.createElement("script"); | |
// onload fires even when script fails loads with an error. | |
script.onload = onload; | |
script.onerror = onerror || onload; | |
script.src = url; | |
document.head.appendChild(script); | |
} |
View video_converter.sh
#!/bin/bash | |
#author : Kichrum | |
files=$(ls *.avi); | |
outputFolder="output/" | |
for file in $files | |
do | |
outputFile=${file//.avi/}; | |
printf "\n\n === Converting $file => $outputFile.mp4 === \n"; |
View inherit_es5.js
/** | |
* Inheritance in ES5 | |
* @author Kichrum | |
*/ | |
var inherit = function(Parent) { | |
var Child = function(){ Parent.apply(this, arguments) } | |
Child.prototype = Object.create(Parent.prototype) | |
return Child | |
} |
View inherit.js
/** | |
* One more version of inheritance for ES3 | |
* @author Kichrum | |
*/ | |
var inherit = function(Parent) { | |
var Child = function(){ Parent.apply(this, arguments) } | |
// We can use | |
// Child.prototype = Object.create(Parent.prototype) | |
// here for ES5 instead of next 3 lines: |
NewerOlder