Tutorial by Examples: c

You can specify a file to a ps1-script to execute it's content on launch using the -File parameter. Basic script MyScript.ps1 (Get-Date).ToShortDateString() "Hello World" Output: >PowerShell.exe -File Desktop\MyScript.ps1 10.09.2016 Hello World Using parameters and argument...
public static async Task PostAsync(this Uri uri, object value) { var content = new ObjectContext(value.GetType(), value, new JsonMediaTypeFormatter()); using (var client = new HttpClient()) { return await client.PostAsync(uri, content); } } . . . var uri = new ...
public static async Task<TResult> GetAnsync<TResult>(this Uri uri) { using (var client = new HttpClient()) { var message = await client.GetAsync(uri); if (!message.IsSuccessStatusCode) throw new Exception(); return message.ReadAsAsyn...
from py2neo import authenticate, Graph, Node, Relationship authenticate("localhost:7474", "neo4j", "<pass>") graph = Graph() You have to make sure your Neo4j Database exists at localhost:7474 with the appropriate credentials. the graph object is your interfa...
def get_autocomplete(text): query = """ start n = node(*) where n.name =~ '(?i)%s.*' return n.name,labels(n) limit 10; """ query = query % (text) obj = [] for res in graph.cypher.execute(query): # print res[0],res[1] obj.a...
def search_news_by_entity(location,timestamp): query = """ MATCH (n)-[]->(l) where l.name='%s' and n.timestamp='%s' RETURN n.news_id limit 10 """ query = query % (location,timestamp) news_ids = [] for res in graph.cypher.e...
Count articles connected to a particular person over time MATCH (n)-[]->(l) where l.name='Donald Trump' RETURN n.date,count(*) order by n.date Search for other People / Locations connected to the same news articles as Trump with at least 5 total relationship nodes. MATCH (n:NewsArticle)-[...
Text fields can have different input types, such as number, date, password, or email address. The type determines what kind of characters are allowed inside the field, and may prompt the virtual keyboard to optimize its layout for frequently used characters. By default, any text contents within an ...
Nested list comprehensions, unlike list comprehensions with nested loops, are List comprehensions within a list comprehension. The initial expression can be any arbitrary expression, including another list comprehension. #List Comprehension with nested loop [x + y for x in [1, 2, 3] for y in [3, 4...
An F() object represents the value of a model field or annotated column. It makes it possible to refer to model field values and perform database operations using them without actually having to pull them out of the database into Python memory. - F() expressions It is appropriate to use F() obj...
Supposing you have setup a django project, and the settings file is in an app named main, this is how you initialize your code import os, sys # Setup environ sys.path.append(os.getcwd()) os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings") # Setup django imp...
Magento has a powerful set of methods to filter collections. Since there are two types of Objects that can be contained in collections, we must first determine which type of data we are working with before we can filter it. Magento implements a EAV data model for entities such as products and catego...
This uses the SwiftyDropbox library to upload a file from a NSFileHandle to the Dropbox account using upload sessions, handling every error case: import UIKit import SwiftyDropbox class ViewController: UIViewController { // filled in later in doUpload: var fileHandle : NSFileHandle?...
var express = require("express"), bodyParser = require("body-parser"), server = express(); //body parser for parsing request body server.use(bodyParser.json()); server.use(bodyParser.urlencoded({ extended: true })); //temperary store for `item` in memory var it...
import curses import traceback try: # -- Initialize -- stdscr = curses.initscr() # initialize curses screen curses.noecho() # turn off auto echoing of keypress on to screen curses.cbreak() # enter break mode where pressing Enter key ...
Use the double negation syntax to check for truthiness of values. All values correspond to a boolean, irrespective of their type. irb(main):001:0> !!1234 => true irb(main):002:0> !!"Hello, world!" (irb):2: warning: string literal in condition => true irb(main):003:0> !...
You do not need to use double negation in if-else statements. if 'hello' puts 'hey!' else puts 'bye!' end The above code prints 'hey!' on the screen.
Lets you compose several functions f₀ f₁ … fₙ. It returns a function that will successively apply fₙ to its arguments, then fₙ₋₁ to the result of fₙ and so on. Function are applied from right to left, like for mathematical function composition: (f ∘ g ∘ h)(x) = f(g(h(x))). > ((compose sqrt +) 16...

Page 502 of 826