1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<!DOCTYPE html>
<html
lang="en">
<head>
<meta
charset="utf-8" />
<title>The Title</title>
<link
rel="stylesheet"
href="style.css" />
<style>
body
{padding:
2em;}
</style>
<script
src="script.js"></script>
</head>
<body>
<nav>
<ul
class="blep">
<li><a
href="https://web.com/">Home</a></li>
<li><a
href="about.html">About</a></li>
</ul>
</nav>
<article>
<h1>The title</h1>
<p>A text with HTML entities & inline tags
<em>like these</em> emphasis tags (…)
</p>
</article>
</body>
</html>
@charset "UTF-8";
@import
url(print.css);
@font-face {
font-family: Chunkfive;
src:
url('chunk5.woff2')
format('woff2');
font-weight: normal;
font-style: normal;
}
body, .usertext
{
color: #F0F0F0
!important;
background-color:
rgba(255,
0, 0, 0.6);
font:
400 1.25rem/1.3 Chunkfive,
sans-serif;
--heading-1:
30px/32px
Times, serif;
}
@media print
and (max-width:
600px) {
div +
a[href$=".pdf"]::before {
content:
" ("
attr(href)
")";
color:
hsla(120%,
100%, 50%,
0.3);
}
}
/* single line comment */
@import
"compass/reset";
$colorGreen: #008000;
$colorGreenDark:
darken($colorGreen,
10);
@mixin container {
max-width: 980px;
}
$content: "First content";
$content: "Second content?" !default;
// mixins with parameters
@mixin button($color:green) {
@if ($color ==
green) {
background-color: #008000;
}
@else if
($color == red) {
background-color: #B22222;
}
}
input[type="input"] {
font-family: Arial,
sans-serif;
}
$font-stack: Helvetica, sans-serif
body
font: 100% $font-stack
article[role="main"]
width:
600px / 960px * 100%
=transform($property)
-webkit-transform: $property
transform: $property
.box
+transform(rotate(30deg))
%message-shared
border: 1px solid #ccc
.message
@extend %message-shared
@for
$i from 1 through $squareCount
#square-#{$i}
width: 50px * $i
height: 120px / $i
@import "library";
// library.less
@base: #f04615;
@width: 0.5;
.bordered {
border-top: dotted 1px
black;
}
.class {
width:
percentage(@width);
// returns `50%`
background-color:
spin(lighten(@base,
5%), 8);
&.title {
.bordered() !important;
}
}
.component {
width: 300px;
@media
(min-width: 768px) {
width: 600px;
@media
(min-resolution: 192dpi) {
background-image:
url(/img/retina2x.png);
}
}
}
var x,
window = this,
string = new String('string\n'),
document = window.document,
simpleExpr = /^#?([\w-]+)$/;
function $initHighlight(block,
cls) {
try {
if (cls.search(/\bno\-highlight\b/)
!= -1)
return process(block, true,
0x0F) +
` class=""`;
} catch (e) {
/* handle exception */
}
for (var i = 0 /
2; i < classes.length; i++) {
if (checkCondition(classes[i])
=== undefined)
console.log('undefined');
}
return (
<web-component> block</web-component>
)
}
export $initHighlight;
{Overlord} = require
'megalomania'
failsafe = require 'failsafe-plus'
evilPlan = require 'overthrowCapitalism'
timeframe = require 'timeframe'
module.exports =
class DefaultOverlordCogitation
overlordStrategy: (musings) ->
doneEvilPlan = doEvilPlan(musings)
{host}
= timeframe.parse(musings)
overlordEvilPlan = if host
musings
else if not
failsafe.isOverlordMedicated(doneEvilPlan)
evilPlan.eureka(doneEvilPlan)
else
doneEvilPlan
# TODO: Cackle when EvilPlan is realized.
overlord = new Overlord(overlordEvilPlan)
if host
overlord.evilPlan = overlordEvilPlan
if failsafe.isNotInPlace()
overlord.EvilPlan =
overlordEvilPlan.toPasture()
overlord
function checkValidSW(swUrl: string) {
// Check if the SW can be found. If not, reload.
fetch(swUrl)
.then(res => {
// Ensure SW exists and that we get a JS file.
if (
res.status === 404 ||
res.headers.get('content-type')!.indexOf('js') === -1
) {
// No SW found. Probably a different app. Reload.
navigator.serviceWorker.ready.then(registration => {
registration.unregister().then(()
=> {
window.location.reload();
});
});
} else {
// SW found. Proceed as normal.
registerValidSW(swUrl);
}
})
.catch(() => {
console.log('No internet connection found.');
});
}
<?php
require_once 'check/injection.php';
namespace Location\Web;
$url = "www.guru99.com";
if (preg_match("/guru/",
$url)) {
echo "the url $url contains guru";
}
else {
echo "the url $url does not contain guru";
}
$text = "I Love Regular Expressions";
$array =
preg_split("/ /",
$text);
print_r($array);
$email = "name@company.com";
if
() {
echo "$email is a valid email address";
}
else {
echo "$email is NOT a valid email address";
}
?>
import java.io.*;
public class KeyboardIntegerReader {
public static
void main
(String[]
args) throws java.io.IOException {
String s1;
String s2;
int num = 0;
// set up the buffered reader to read from the keyboard
BufferedReader br =
new BufferedReader (new InputStreamReader (
System.in));
boolean cont = true;
while (cont) {
System.out.print
("Enter an integer:");
s1 = br.readLine();
StringTokenizer st =
new StringTokenizer (s1);
s2 = "";
catch (NumberFormatException
n) {
System.out.println("The value in
\"" + s2 +
"\" is not an integer");
}
}
System.out.println
("You entered the integer: " + num);
}
}
package io.realm.examples.kotlin
import io.realm.examples.kotlin.model.Person
class KotlinExampleActivity : Activity() {
override fun onDestroy() {
super.onDestroy()
realm.close() // Close Realm when done.
}
private fun complexQuery(): String {
var status =
"\n\nPerforming complex Query operation..."
Realm.getDefaultInstance().use {
// 'it' = implicit lambda parameter of type Realm
status += "\nNo. of persons:
${it.where(Person::class.java).count()}"
val results = it
.where(Person::class.java)
.between("age",
7, 9) // Implicit "and" operation
.beginsWith("name", "Person")
.findAll()
status += "\nSize of result set: ${results.size}"
}
return status
}
}
# Using re's to break up a line.
print "Please enter a line: "
line = gets.chomp
res = [ ]
while res != ''
# String leading blanks.
line.sub!(/^\s*/,
'')
break if line == ''
# See what the leading is for next action.
if line[0].chr == '"' then
# Quoted.
line.sub!(/^"([^"]*)"/, '')
res.push($1)
elsif
line.sub!(/^(\d+):(\S+)/,
'')
# Repeated with n:
$1.to_i.times { res.push($2) }
else
# Just a word.
line.sub!(/^(\S+)/, '')
res.push($1)
end
end
# A game of Hangman
from include.model import model, lr
from include.data import get_data_set
import math
from time import time
import tensorflow as tf
import numpy as np
from string import ascii_lowercase
from words import get_random_word
def get_num_attempts():
"""Get number of incorrect attempts."""
while True:
num_attempts = input(
'How many incorrect attempts do you want? [1-9] ')
try:
num_attempts = int(num_attempts)
if 1 <= num_attempts <= 9:
return num_attempts
else:
print('{0} is not between 1 and 9'.format(num_attempts))
except ValueError:
print('{0} is not an integer between 1 and 9'.format(
num_attempts))
(ns clojurebreaker.game
(:use clojure.pprint)
(:require [clojure.data :as
data]
[clojure.math.combinatorics
:as comb]
[clojure.java.io :as
io]))
;; START:exact-matches
(defn exact-matches
"Given two collections, return the number of positions
where the collections contain equal items."
[c1 c2]
(let
[[_ _ matches]
(data/diff c1 c2)]
(count
(remove nil? matches))))
;; END:exact-matches
;; START:unordered-matches
(defn unordered-matches
"Given two collections, return a map where each key is an item
in both collections and each value is the number of times the
value occurs in the collection with fewest occurrences."
[c1 c2]
(let [f1
(select-keys (frequencies
c1) c2)
f2 (select-keys
(frequencies c2) c1)]
(merge-with min
f1 f2)))
;; END:unordered-matches
#!/usr/bin/perl
use strict;
use warnings;
# first, create your message
use Email::MIME;
my $message
= Email::MIME->create(
header_str => [
From =>
'you@example.com',
To =>
'friend@example.com',
Subject => 'Happy birthday!',
],
attributes => {
encoding => 'quoted-printable',
charset =>
'ISO-8859-1',
},
body_str =>
"Happy birthday to you!\n",
);
# send the message
use
Email::Sender::Simple
qw(sendmail);
sendmail($message);
// Target function example:
func ExtractUsername(email string) string {
at := strings.Index(email, "@")
return email[:at]
}
// Test code:
import (
"testing"
)
func TestExtractUsername(t *testing.T) {
t.Run("withoutDot", func(t *testing.T) {
username := ExtractUsername("r@google.com")
if username != "r" {
t.Fatalf("Got: %v\n", username)
}
})
t.Run("withDot", func(t *testing.T) {
username := ExtractUsername("jonh.smith@web.com")
if username != "jonh.smith" {
t.Fatalf("Got: %v\n", username)
}
})
}
library app;
import 'dart:html';
part 'app2.dart';
@Awesome('it works!')
class Item<S extends
Iterable> implements Comparable {
factory Item(num param);
Item._internal(int q) : super() {
assert(q != 1);
double z = 0.0;
}
/// **Sum** function
int sum(int a,
int b) => a + b;
ElementList els() =>
querySelectorAll('.dart');
}
String str = ' (${'parameter' + 'zxc'})';
String str = " ($variable)";
var str = '''
Something ${2+3}
''';
checkVersion() async {
var version = await lookUpVersion();
}
<?xml version="1.0"?>
<catalog>
<book id="bk101">
<author>Corets, Eva</author>
<title>Maeve Ascendant</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-11-17</publish_date>
<description>
After the collapse of nanotech in England, the
survivors lay the foundation for a new society.
</description>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>
A former architect battles corporate zombies and
her own childhood to become queen of the world.
</description>
</book>
</catalog>
{
"users": [
{
"userId": 1,
"firstName": "Jet",
"lastName": "Li",
"phoneNumber": "555-JACKIESUX",
"emailAddress": "hey_im_down_here@li.com"
},
{
"userId": 2,
"firstName": "Sylvester",
"lastName": "Stallone",
"phoneNumber": "555-PUNCHRUSSKI",
"emailAddress": "rambito.lindo@bang.com"
},
{
"userId": 3,
"firstName": "Steven",
"lastName": "Seagal",
"phoneNumber": "555-GOTFAT",
"emailAddress": "waxface@itappedkelly.com"
}
]
}
# YAML
---
doe: "a deer, a female deer"
ray: "a drop of golden sun"
pi: 3.14159
xmas: true
french-hens: 3
calling-birds:
- huey
- dewey
- louie
- fred
xmas-fifth-day:
calling-birds: four
french-hens: 3
golden-rings: 5
partridges:
count: 1
location: "a pear tree"
turtle-doves: two
--- # Favorite movies
- Casablanca
- North by Northwest
- The Man Who Killed Liberty Valance
title = "TOML Example"
[owner]
name = "Tom Preston-Werner"
dob = 1979-05-27T07:32:00-08:00
[database]
server = "192.168.1.1"
ports = [ 8001,
8001, 8002 ]
enabled = true
[servers]
# Indentation allowed
[servers.alpha]
ip = "10.0.0.1"
dc = "eqdc10"
[servers.beta]
ip = "10.0.0.2"
dc = "eqdc10"
[clients]
hosts = [
"alpha",
"omega"
]
SELECT file_hash -- stored ssdeep hash
FROM file_system
WHERE file_name = '.vimrc';
/* Updating the file record after writing to the file */
UPDATE file_system
SET file_modified_date = '1980-02-22 13:19:01.00000',
file_size = 209732
WHERE file_name = '.vimrc';
SELECT first_name AS fn
FROM staff AS s1
JOIN students AS s2
ON s2.mentor_id =
s1.staff_num;
SELECT SUM(s.monitor_tally)
AS monitor_total
FROM staff AS s;
(SELECT f.species_name,
AVG(f.hght)
AS height, AVG(f.dmtr)
AS diameter
FROM flora AS f
WHERE f.species_name = 'Banksia'
OR f.species_name = 'Sheoak'
OR f.species_name = 'Wattle'
GROUP BY f.species_name,
f.observation_date)
# Markdown
Attributes _italic_, **bold**, `monospace`, ~~strikethrough~~.
+ Create a list by starting a line with `+`, `-`, or `*`
+ Sub-lists are made by indenting 2 spaces:
- Marker character change forces new list start:
+ A link [example](http://example.com).
> Markdown uses email-style > characters for blockquoting.
```
Sample code or text...
```
``` js
function
hello(name) {
let phrase =
`Hello, ${name}!`;
say(phrase);
}
```
{~~One~>Only one~~} thing is impossible for God: To find {++any++}
sense in any copyright law on the planet. {==Truth is stranger
than fiction==}{>>strange but true<<},
{--but it is--} because
fiction is obliged to stick to possibilities; truth isn’t.
exec 10<&0 # Link filedescriptor 10 with stdin
exec < 1 # stdin replaced with a file (1st argument)
in=1 # remember the name of the input file
file="current_line.txt" # init
let count=0
while read LINE # iterate over all lines of the file
do
((count++)) # increase line counter
echo LINE >
file # write current line to a tmp file
if [ ? -ne 0 ] # check the return code of echo
then echo
"Error in writing to file file "
fi
done
echo "Number of lines: count"
echo "The last line of the file is: `cat
file `"
# You can achieve the same byt using the tool wc:
echo "Expected number of lines: `wc -l
in`"
# restore stdin from filedescriptor 10
# and close filedescriptor 10
exec 0<&10 10<&-
IDIR = ../include
CC = gcc
CFLAGS = -I$(IDIR)
ODIR = obj
LDIR = ../lib
LIBS = -lm
_DEPS = hellomake.h
DEPS = $(patsubst
%, $(IDIR)/%,
$(_DEPS))
_OBJ = hellomake.o hellofunc.o
OBJ =
$(patsubst
%, $(ODIR)/%,
$(_OBJ))
$(ODIR)/%.o: %.c $(DEPS)
$(CC) -c -o $@
$< $(CFLAGS)
hellomake : $(OBJ)
$(CC) -o $@
$^ $(CFLAGS)
$(LIBS)
.PHONY : clean
clean :
rm -f
$(ODIR)/*.o
*~ core $(INCDIR)/*~
<!-- Tabs -->
<div id="{{ uniqid }}-tab-container">
<ul
role="tablist"
class="nav nav-tabs">
{{# tabs }}
<li role="tab"
data-target="{{ uniqid }}-{{ id }}"
data-selected-class="active"
aria-controls="{{ uniqid }}-{{ id }}"
aria-selected="false"
tabindex="-1">
<a
href="#">{{{ name
}}}</a>
</li>
{{/ tabs }}
</ul>
<div
class="tab-content">
{{# tabs }}
<div
role="tabpanel"
class="tab-pane"
id="{{ uniqid
}}-{{ id }}">
{{{ content }}}
</div>
{{/ tabs }}
</div>
</div>
#import "Fraction.h"
@implementation Fraction
@synthesize numr, denm;
- (double)convertToNum {
if (denm != 0)
return (double) numr / denm;
else
return NAN;
}
- (NSString *)convertToString {
if (numr == denm) {
if (numr == 0)
return @"0";
else
return @"1";
}
else if (denm == 1)
return
[NSString stringWithFormat:@"%i", numr];
else
return
[NSString
stringWithFormat:@"%i/%i", numr, denm];
}
#include <stdio.h>
int main() {
int i, space, rows, k =
0, count = 0, count1 = 0;
printf("Enter the number of rows: ");
scanf("%d",
&rows);
for (i = 1; i <= rows;
++i) {
for (space = 1; space
<= rows - i; ++space) {
printf("
");
++count;
}
while (k != 2
* i - 1) {
if (count <= rows -
1) {
printf("%d ", i
+ k);
++count;
} else {
++count1;
printf("%d ",
(i + k - 2 * count1));
}
++k;
}
count1 = count = k = 0;
printf("\n");
}
return 0;
}
// C# Program to Perform Text Operations in a File
using System;
using System.IO;
class Program {
static void Main() {
FileInfo finfo = new
FileInfo("C:\\sk\\sk.txt");
using (StreamWriter writer =
finfo.AppendText())
{
writer.WriteLine("New File with Text operations");
}
finfo = new
FileInfo("C:\\sk\\sk.txt");
using (StreamWriter writer =
finfo.CreateText()) {
writer.WriteLine("New File with Text operations");
}
using (StreamReader reader =
finfo.OpenText()) {
Console.WriteLine(reader.ReadToEnd());
}
Console.Read();
}
}