Skip to content

Instantly share code, notes, and snippets.

@sunnydoll
sunnydoll / file_crtime.bash
Created May 6, 2018 03:05
create time of file in linux
ls -i file #output is for me 68551981
debugfs -R 'stat <68551981>' /dev/sda3 # /dev/sda3 is the disk on which the file exists
#results - crtime value
[root@loft9156 ~]# debugfs -R 'stat <68551981>' /dev/sda3
debugfs 1.41.12 (17-May-2010)
Inode: 68551981 Type: regular Mode: 0644 Flags: 0x80000
Generation: 769802755 Version: 0x00000000:00000001
User: 0 Group: 0 Size: 38973440
File ACL: 0 Directory ACL: 0
@sunnydoll
sunnydoll / LDAPAddUser.java
Created July 26, 2016 20:19
Adding user into AD
package model;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;
import javax.naming.directory.BasicAttribute;
import javax.naming.directory.BasicAttributes;
@sunnydoll
sunnydoll / EpplusSaveMultipleTimes.cs
Created June 29, 2016 02:57
Saving to xlsx file multiple times without closing the stream
public void Multi_Save_Test()
{
//http://stackoverflow.com/questions/28007087/how-to-write-to-excel-many-times-using-one-object-of-epplus-in-c-sharp
var existingFile = new FileInfo(@"c:\temp\temp.xlsx");
if (existingFile.Exists)
existingFile.Delete();
//Use memstream and create the package but WITHOUT the FI so it is a memory stream as well
//Avoid using and call manual dispose
var holdingstream = new MemoryStream();
@sunnydoll
sunnydoll / JSONStringToObject.cs
Last active June 22, 2016 18:34
JSON string to an object which is very useful. Tricky keyword dynamic.
WebRequest request = WebRequest.Create(connectURL);
//request.Headers.Add(HttpRequestHeader.ContentType, "application/json");
request.Method = "GET";
WebResponse response = request.GetResponse();
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
// Get the stream containing content returned by the server.
Stream dataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream);
// Read the content.
@sunnydoll
sunnydoll / index.html
Created December 2, 2015 17:07
HTML5 Input Type=date Working under IE 11
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title> - jsFiddle demo</title>
</head>
<body>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/webshim/1.14.5/polyfiller.js"></script>
<script>
@sunnydoll
sunnydoll / reg.js
Created December 1, 2015 20:22
Regexp for normal chars
function filterSpecialChar(text) {
var patt = /[^a-zA-Z0-9{}.,\?'"\[\]\(\)\-\\\/:&;\*@\s]+/;
if(patt.test(text))
return false;
else
return true;
}
@sunnydoll
sunnydoll / app.js
Created December 1, 2015 20:20
Programmatically Insert Ember Component
var app = Ember.Application.create();
app.ApplicationController = Ember.Controller.extend({
modals: Ember.inject.service(),
// init: function() {
// console.log(this.get('modals'));
// },
actions: {
openModal: function(name) {
this.get('modals').open(name);
@sunnydoll
sunnydoll / select.html
Created November 25, 2015 19:34
Auto-complete dropdown list by JQuery
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Autocomplete - Combobox</title>
<link rel="stylesheet" href="https:///code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script src="https:///code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<style>
@sunnydoll
sunnydoll / Delete lowest score of homework type.js
Created October 29, 2015 01:55
MongoDB query for deleting the lowest score from scores array with type of homework
{
"_id" : 137,
"name" : "Tamika Schildgen",
"scores" : [
{
"type" : "exam",
"score" : 4.433956226109692
},
{
@sunnydoll
sunnydoll / Xml2Json
Created October 5, 2015 15:37
Convertion between XML and JSON
<body>
<h1>X2JS Demo</h1>
<button id="convertToJsonBtn">XML => JSON</button>
<button id="convertToXmlBtn">JSON => XML</button>
<div>
<h4>XML:</h4>
<textarea id="xmlArea" cols="55" rows="15"></textarea>
</div>