C++ code style written in markdown.
Astyle code automatic formatting settings
You can use clang-format too.
Use tools like vera++
| #Packet sniffer in python for Linux | |
| #Sniffs only incoming TCP packet | |
| import socket, sys | |
| from struct import * | |
| #create an INET, STREAMing socket | |
| try: | |
| s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_TCP) | |
| except socket.error , msg: |
| /** | |
| * Solves the n-Queen puzzle in O(n!) | |
| * Let p[r] be the column of the queen on the rth row (must be exactly 1 queen per row) | |
| * There also must be exactly 1 queen per column and hence p must be a permuation of (0 until n) | |
| * There must be n distinct (col + diag) and n distinct (col - diag) for each queen (else bishop attacks) | |
| * @return returns a Iterator of solutions | |
| * Each solution is an array p of length n such that p[i] is the column of the queen on the ith row | |
| */ | |
| def nQueens(n: Int): Iterator[Seq[Int]] = | |
| (0 until n) |
| #ifndef _MACARON_BASE64_H_ | |
| #define _MACARON_BASE64_H_ | |
| /** | |
| * The MIT License (MIT) | |
| * Copyright (c) 2016-2024 tomykaira | |
| * | |
| * Permission is hereby granted, free of charge, to any person obtaining | |
| * a copy of this software and associated documentation files (the | |
| * "Software"), to deal in the Software without restriction, including |
C++ code style written in markdown.
Astyle code automatic formatting settings
You can use clang-format too.
Use tools like vera++
Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.
A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.
val square : Int => Int = x => x * x| -- Create a group | |
| CREATE ROLE readaccess; | |
| -- Grant access to existing tables | |
| GRANT USAGE ON SCHEMA public TO readaccess; | |
| GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess; | |
| -- Grant access to future tables | |
| ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess; |
| /*** | |
| * Excerpted from "The Definitive ANTLR 4 Reference", | |
| * published by The Pragmatic Bookshelf. | |
| * Copyrights apply to this code. It may not be used to create training material, | |
| * courses, books, articles, and the like. Contact us if you are in doubt. | |
| * We make no guarantees that this code is fit for any purpose. | |
| * Visit http://www.pragmaticprogrammer.com/titles/tpantlr2 for more book information. | |
| ***/ | |
| import org.antlr.v4.runtime.*; | |
| import org.antlr.v4.runtime.tree.ParseTree; |
A short demo showing the explicit instantiation of templates, and how to avoid parsing the full definition(s) in every compilation unit. The limitation is that it will only be possible to use the specific specialisations explicitly instantiated in the cpp file.
| SELECT | |
| *, | |
| pg_size_pretty(table_bytes) AS table, | |
| pg_size_pretty(index_bytes) AS index, | |
| pg_size_pretty(total_bytes) AS total | |
| FROM ( | |
| SELECT | |
| *, total_bytes - index_bytes - COALESCE(toast_bytes, 0) AS table_bytes | |
| FROM ( | |
| SELECT |
| /** | |
| * @file endianness.h | |
| * @brief Convert Endianness of shorts, longs, long longs, regardless of architecture/OS | |
| * | |
| * Defines (without pulling in platform-specific network include headers): | |
| * bswap16, bswap32, bswap64, ntoh16, hton16, ntoh32 hton32, ntoh64, hton64 | |
| * | |
| * Should support linux / macos / solaris / windows. | |
| * Supports GCC (on any platform, including embedded), MSVC2015, and clang, | |
| * and should support intel, solaris, and ibm compilers as well. |