Posts

Showing posts from May, 2014

Convert Unix Timestamp To Human-readable Time

Answer : If the line starts with the unix timestamp, then this should do it: perl -pe 's/^(\d+)/localtime $1/e' inputfilename perl -p invokes a loop over the expression passed with -e which is executed for each line of the input, and prints the buffer at the end of the loop. The expression uses the substition command s/// to match and capture a sequence of digits at the beginning of each line, and replace it with the local time representation of those digits interpreted as a unix timestamp. /e indicates that the replacement pattern is to be evaluated as an expression. If your AWK is Gawk, you can use strftime : gawk '{ print strftime("%c", $1) }' will convert the timestamp in the first column to the current locale’s default date/time representation. You can use this to transform the content before viewing it: gawk '{ print gensub($1, strftime("%c", $1), 1) }' inputfile As Dan mentions in his answer, the Gnu date(1) command can be give

C++ Print Double With 2 Decimal Places Code Example

Example 1: how to specify how many decimal to print out with std::cout # include <iostream> # include <iomanip> int main ( ) { double d = 122.345 ; std :: cout << std :: fixed << std :: setprecision ( 2 ) << d ; } //result that get print out: 122.34 Example 2: how to format decimal palces in c++ std :: cout << std :: setprecision ( 2 ) << std :: fixed ; // where the 2 is how many decimal places you want // note you need to <iomanip>

Android Sdk Missing Android Studio Code Example

Example: android stdio doesnt come with the sdk Go to the SDK Manager and click Edit... next to the field for the location of the SDK. Then an "SDK Setup" window should display. There you can download the SDK.

Border Height On CSS

Answer : I have another possibility. This is of course a "newer" technique, but for my projects works sufficient. It only works if you need one or two borders. I've never done it with 4 borders... and to be honest, I don't know the answer for that yet. .your-item { position: relative; } .your-item:after { content: ''; height: 100%; //You can change this if you want smaller/bigger borders width: 1px; position: absolute; right: 0; top: 0; // If you want to set a smaller height and center it, change this value background-color: #000000; // The color of your border } I hope this helps you too, as for me, this is an easy workaround. No, there isn't. The border will always be as tall as the element. You can achieve the same effect by wrapping the contents of the cell in a <span> , and applying height/border styles to that. Or by drawing a short vertical line in an 1 pixel wide PNG which is the correct height, and applying it

Button Css Generator Online Code Example

Example: css button generator <!-- The <button> tag produces a button. Place the text/media you want to be on the button by placing it between the opening and closing tags: --> < button > Click me! </ button > <!-- It is possible to add attributes, such as 'id' and 'type', into the opening tag, just like most other elements: --> < button id = " submitButton " type = " submit " > Click here to submit! </ button >

Copy Files Between Two Remote Servers With SFTP

Answer : To enable file transfer between two remote machines, you'll need to SSH/Telnet/Remote/VNC etc. into one of them and initiate the transfer from there. Any other alternative involving your local machine will necessitate transferring the files to your local first.

Android XXHDPI Resources

Answer : According to the post linked in the G+ resource: The gorgeous screen on the Nexus 10 falls into the XHDPI density bucket. On tablets, Launcher uses icons from one density bucket up [0] to render them slightly larger. To ensure that your launcher icon (arguably your apps most important asset) is crisp you need to add a 144*144px icon in the drawable-xxhdpi or drawable-480dpi folder. So it looks like the xxhdpi is set for 480dpi. According to that, tablets use the assets from one dpi bucket higher than the one they're in for the launcher. The Nexus 10 being in bucket xhdpi will pull the launcher icon from the xxhdpi. Source Also, was not aware that tablets take resources from the asset bucket above their level. Noted. The DPI of the screen of the Nexus 10 is ±300, which is in the unofficial xhdpi range of 280‑400. Usually, devices use resources designed for their density. But there are exceptions, and exceptions might be added in the future. T

Converting A Mongo Stored Date Back Into Milliseconds Since Unix Epoch When Loaded?

Answer : You can add the numerical milliseconds version of timestamp as a virtual attribute on the schema: schema.virtual('timestamp_ms').get(function() { return this.timestamp.getTime(); }); Then you can enable the virtual field's inclusion in toObject calls on model instances via an option on your schema: var schema = new Schema({ timestamp: Date }, { toObject: { getters: true } }); var schema = new Schema({ timestamp: {type:Number, default: new Date().getTime()} }); Hope this will solve your issue. As a best practice, I would say: keep your data the type it deserves . Anyway, if your client needs to treat with numbers, you can simply pass the date as milliseconds to the client, and still work with Date objects in Node. Just call timestamp.getTime() and ta-da, you have your unix timestamp ready for the client.

Factoring Calculator With Steps Code Example

Example: calculate factorial int factorial ( int n ) { int res = 1 , i ; for ( i = 2 ; i <= n ; i ++ ) res *= i ; return res ; }

Converting String To Int Php Code Example

Example 1: php string to int intval ( $string ) ; Example 2: convert to int php $myintvariable = intval ( $myvariable ) ; Example 3: Convert a String to a Number in PHP phpCopy $variableName = ( int ) $stringName $variableName = ( float ) $stringName Example 4: convert string to int php intval ( mixed $var [ , int $base = 10 ] ) : int

41 Minute Timer Code Example

Example: 20 minute timer for good eyesight every 20 minutes look out the window at something 20 feet away for 20 seconds

Can't Install Xdebug On Mac With Homebrew

Answer : Add this repository: https://github.com/josegonzalez/homebrew-php#readme Then use brew install php54-xdebug for PHP 5.4 Or brew install php53-xdebug for PHP 5.3 Or brew install php55-xdebug for PHP 5.5 // Working as of 2021 As homebrew removed the extra php repository containing a version with xdebug already installed, you have to install it manually. Summary: brew install <php version> for php update your path pecl install xdebug for xdebug Full example: # update homebrew brew update # install a version of php, e.g. 7.0 brew install php@7.0 # now they tell you how to link it, in my case echo 'export PATH="/usr/local/opt/php@7.0/bin:$PATH"' >> ~/.bash_profile echo 'export PATH="/usr/local/opt/php@7.0/sbin:$PATH"' >> ~/.bash_profile # reload the file with the updated path, so we can use pecl source ~/.bash_profile # check that the path is to the correct php executable, # and pecl is available whi

Android Glide Library Github Code Example

Example: android glide dependency dependencies { implementation 'com.github.bumptech.glide:glide:4.11.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0' }

How To Make Your Text Bold In Css Code Example

Example 1: css bold text .text { font-weight : bold ; } Example 2: css text bold font-weight : bold ; Example 3: css bold text /* Keyword values */ font-weight : bold ; /* Keyword values relative to the parent */ font-weight : bolder ; /* Numeric keyword values */ font-weight : 700 ; // bold font-weight : 800 ; font-weight : 900 ;

How To Remove Wondershare Filmora Watermark Code Example

Example 1: how to remove filmora watermark Here How To Get Filmora 9 For Free WITHOUT Watermark [ Filmora X is Available Also ] 0. Disable Anti Virus Cuz You Gotta Install . DLL Files 1. Download and Setup Filmora 9 2. Watch The Video Video 3. Downlaod The Files in Desc Do as it Says 4. Login or Sign up and Make a Filmora Account 5. Enjoy Your Filmora WITHOUT The Watermark YouTube Video : https : //www.youtube.com/watch?v=78dC55fduQU Cracked Files : https : //drive.google.com/file/d/1qC9UfD3ixW5iMaYfP50W8IwSZybToel8/view Thank me On Discord : Rigby# 9052 Example 2: how to remove filmora watermark for free thanks my dude it worked

Css Disable Button Code Example

Example 1: javascript how to disable a button //Using Javascript //Disabling a html button document.getElementById("Button").disabled = true; //Enabling a html button document.getElementById("Button").disabled = false; //Using jQuery //Disabling a html button $('#Button').attr('disabled','disabled'); //Enabling a html button $('#Button').removeAttr('disabled'); Example 2: style disabled button button:disabled, button[disabled]{ border: 1px solid #999999; background-color: #cccccc; color: #666666; } Example 3: css disable button click button.disabled{ pointer-events: none; } Example 4: html button disabled This button is disabled Example 5: css for disabled button /* CSS Selectors for CSS2 and CSS3 both */ button:disabled, button[disabled]{ border: 1px solid #999999; background-color: #cccccc; color: #666666; }

Css To Scss Converter\ Code Example

Example 1: sass to scss # You can do it with SASS itself # Nevermind these malware infested sites below sass-convert style.sass style.scss Example 2: scss to css Use the "Live Sass Compiler" in Visual Studio Code

Bootstrap Responsive Background Image Code Example

Example 1: add background image in bootstrap 5 < div class = " has-bg-img bg-purple bg-blend-screen " > < h4 > Background blend mode: Multiply </ h4 > < img class = " bg-img " src = " ... " > </ div > Example 2: Scaling Images and Videos css .container { width: 50%; height: 200px; overflow: hidden; } .container img { max-width: 100%; height: auto; display: block; }

CSS Selectors Ul Li A {...} Vs Ul > Li > A {...}

Answer : " > " is the child selector " " is the descendant selector The difference is that a descendant can be a child of the element, or a child of a child of the element or a child of a child of a child ad inifinitum . A child element is simply one that is directly contained within the parent element: <foo> <!-- parent --> <bar> <!-- child of foo, descendant of foo --> <baz> <!-- descendant of foo --> </baz> </bar> </foo> for this example, foo * would match <bar> and <baz> , whereas foo > * would only match <bar> . As for your second question: Which one is more efficient and why? I'm not actually going to answer this question as it's completely irrelevant to development. CSS rendering engines are so fast that there is almost never* a reason to optimize CSS selectors beyond making them as short as possible. Instead of worrying about micro-optimizations, focus o

Cpp Std Erase Code Example

Example: c++ erase remove std :: vector < int > v = { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } ; v . erase ( std :: remove ( v . begin ( ) , v . end ( ) , 5 ) , v . end ( ) ) ; // v will be {0 1 2 3 4 6 7 8 9}