codes

JavScript Sort array of objects by key

var items = [{label: "bbb", value: "bbb"}, {label: "ccc", value: "ccc"}, {label: "aaa", value: "aaa"}]; var rst = items.sort( function (a, b) { var x = a["label"]; var y = b["label"]; return ((x < y) ? -1 : ((x > y) ? 1 : 0)); });

PHP Show all layers from TIFF image

$tff = "00060001.tif"; try { $images = new Imagick($tff); foreach($images as $i=>$image) { $image->thumbnailImage(768,0); $image->setImageFormat("jpg"); $thumbnail = $image->getImageBlob(); ?> <img src="data:image/jpeg;base64,<?=base64_encode($thumbnail)?>" alt="Red dot" /><br /> <? } $images->clear(); } catch(Exception $e) { echo $e->getMessage(); }

JavaScript Search index in array of objects

function arrayObjectIndexOf(myArray, searchTerm, property) { for (var i = 0, len = myArray.length; i < len; i++) { if (myArray[i][property] === searchTerm) return i; } return -1; }

MS SQL Restrict SQL Server Login access to only one database

create LOGIN hello WITH PASSWORD='foo', CHECK_POLICY = OFF; -- Step 2:(deny view to any database) USE master; GO DENY VIEW ANY DATABASE TO hello; -- Step 3 (then authorized the user for that specific database , you have to use the master by doing use master as below) USE master; GO ALTER AUTHORIZATION ON DATABASE::yourDB TO hello; GO

CSS LESS RGBA in Less

will return background-color: rgba(255, 0, 0, 0.5); background-color:fade(@color, 50%);

CSS Material icons

View full icons list <link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <i class="material-icons">add</i> <i class="material-icons">flag</i> <i class="material-icons">help</i>

AngularJS create table with property name as column name

<table class="table-w"> <thead> <tr class="row-head"> <td class="single-field-head" data-ng-repeat="(key, value) in myObj[0]">{{key}}</td> </tr> </thead> <tbody> <tr class="row-autocomplete" data-ng-repeat="r in myObj"> <td data-ng-repeat="(key, value) in r">{{value}}</td> </tr> </tbody> </table>

C# Get Calling function name from Called function

var callingMethod = new StackFrame(1, true).GetMethod(); string source = callingMethod.ReflectedType.FullName + ": " + callingMethod.Name;

CSS LESS LESS and conditional comments

<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]--> .generic_input { padding: 5px 10px 5px 10px; width: ~"calc(100% - 22px)"; height: 24px; .lt-ie9 & { padding: 5px 0 5px 0; width: 100%; } }

CSS Margin bottom IE fix

Bottom margin in internet explorer does not work .dialog-item { width: 880px; background-color: #fff; left: 50%; top: 50px; margin-left: -450px; position: absolute; } .dialog-item:after { content: ''; position:absolute; width: 100%; display: block; height: 50px; bottom:-50px; }

how to Tell If a Program is 64-bit or 32-bit

Right click on it or press and hold and then select Properties. Next, open the Compatibility tab. Here, you need to check the "Run this program in compatibility mode for" box, and open the drop-down list. If the list starts with Windows 95, then the application you selected is a 32-bit application.

CSS Transparent Background Images

.top-section { width: 100%; height: 100%; overflow: auto; background-color: rgba(0, 0, 0, 0.5); } .top-section::after { background-image: url(Images/home.jpg); background-repeat: no-repeat; background-size: 100% auto; background-position: center center; content: ""; width: 100%; height: 100%; top: 0; left: 0; bottom: 0; right: 0; position: absolute; z-index: -1; }

CSS CSS calc

width: -webkit-calc(100% - 10px); width: -moz-calc(100% - 10px); width: calc(100% - 10px); padding:5px;

php js highlight js XML

highlight xml code <?=str_replace(">", "&gt;", str_replace("<", "&lt;", "your_code_here"))?>

ms-dos The User Profile service failed the sign-in

However, if you wanted to play it safe, you could reset the permissions on that folder to inherit from parent instead. rmdir /S C:\Users\Default\AppData\Local\Microsoft\VSCommon

vb.net Set file path for ConfigurationManager.AppSettings

Dim path__1 = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) Dim configFilePath = Path.Combine(path__1, "app.config") Dim fileMap As New ExeConfigurationFileMap() fileMap.ExeConfigFilename = configFilePath Dim config As Configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None) Dim myLogName As String = config.AppSettings.Settings("EventLogName").Value

vb.net Select XML single node content

Dim doc As XmlDocument = New XmlDocument() doc.Load("file.xml") Dim giorno As String = doc.SelectSingleNode("/postacert/dati/data/giorno").InnerText