Batch file does not come with a built-in method for replacing nth line of a file except replace and append(> and >>). Using for loops, we can emulate this kind of function.
@echo off
set file=new2.txt
call :replaceLine "%file%" 3 "stringResult"
type "%file...
JSON data
{
"name" : { "first" : "Joe", "last" : "Sixpack" },
"gender" : "MALE",
"verified" : false,
"userImage" : "keliuyue"
}
It takes two lines of Java to turn it into a User insta...
There are benefits to switching the root view controller, although the transition options are limited to those supported by UIViewAnimationOptions, so depending on how you wish to transition between flows might mean you have to implement a custom transition - which can be cumbersome.
You can show t...
So the most used functions on Clojure map and filter have been modified to return transducers (composable algorithmic transformations), if not called with a collection. That means:
(map inc) returns a transducer and so does (filter odd?)
The advantage: the functions can be composed into a single f...
This is a compact guide about how to quickly create an R package from your code. Exhaustive documentations will be linked when available and should be read if you want a deeper knowledge of the situation. See Remarks for more resources.
The directory where your code stands will be refered as ./, an...
The possibilities are endless. as you can use this concept to pull the version number from your build system; such as git and use that version number in your project.
CMakeLists.txt
cmake_minimum_required(VERSION 3.8)
project(project_name VERSION "0.0.0")
configure_file(${path to con...
From the Terminal command line
Get the current URL from Safari
osascript -e 'tell app "safari" to get the url of the current tab of window 1'
Get the active URL in Google Chrome
osascript -e 'tell app "google chrome" to get the url of the active tab of window 1'
Get the name of the web page in Safari
osascript -e 'tell app "safari" to get the name of the current tab of window 1'
Get the title of the web page in Google Chrome
osascript -e 'tell app "google chrome" to get the title of the active tab of window 1'
If you you want to pass some data with the timer trigger you can do it with the userInfoparameter.
Here is the simple approach that gives brief idea about how you can pass the data to triggered method from the Timer.
[Swift 3]
Timer.scheduledTimer(timeInterval: 1.0, target: self, selector:#selec...
In this example, three brief and comprehensive sub-examples are presented:
Loading weights from available pre-trained models, included with Keras library
Stacking another network for training on top of any layers of VGG
Inserting a layer in the middle of other layers
Tips and general rule-of-t...
A vignette is a long-form guide to your package. Function
documentation is great if you know the name of the function you need,
but it’s useless otherwise. A vignette is like a book chapter or an
academic paper: it can describe the problem that your package is
designed to solve, and then show ...
To generate json user model with username, password_hash, email_id, created_at, updated_at, type
mix phoenix.gen.json User users username:string email_id:string password_hash:string timestamps()
np.save and np.load provide a easy to use framework for saving and loading of arbitrary sized numpy arrays:
import numpy as np
a = np.random.randint(10,size=(3,3))
np.save('arr', a)
a2 = np.load('arr.npy')
print a2
When you run mix phoenix.gen.html or mix phoenix.gen.json from command line, migrations are created in priv -> repo -> migrations in your project folder.
To run migrations type mix ecto.migrate.
To generate migrations for your project mix ecto.gen migrations <model_name>
To generate m...
To remove whitespace (spaces, tabs, newlines…) between HTML tags use spaceless tag:
{% spaceless %}
<div>
<span>foo bar </span>
</div>
{% endspaceless %}
{# produces output <div><strong>foo bar </strong></div> #}
If you need ...
This is an example to explain the variations of load events.
onload event
<body onload="someFunction()">
<img src="image1" />
<img src="image2" />
</body>
<script>
function someFunction() {
console.log("Hi! I am l...
In order to use bootstrap, there are 2 cases.
The electron app is connected to internet
The electron app is not connected to internet
For electron apps that are connected to internet, we can just make use of CDN links for bootstrap and include that in our html files.
The problem comes when w...
This example grabs the Node.gitignore file from GitHub's gitignore repository, downloads it to your current working directory and renames it to .gitignore - all very typical actions for someone starting a new node.js project.
$ curl http://github.com/github/gitignore/raw/master/Node.gitignore -o .g...
#!bin/bash
$ string='Question%20-%20%22how%20do%20I%20decode%20a%20percent%20encoded%20string%3F%22%0AAnswer%20%20%20-%20Use%20printf%20%3A)'
$ printf '%b\n' "${string//%/\\x}"
# the result
Question - "how do I decode a percent encoded string?"
Answer - Use printf ...