This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function GetBit(const Value: DWord; const Bit: Byte): Boolean; | |
| begin | |
| Result := (Value and (1 shl Bit)) <> 0; | |
| end; | |
| function EnableBit(const Value: DWord; const Bit: Byte; const TurnOn: Boolean): DWord; | |
| begin | |
| Result := (Value or (1 shl Bit)) xor (Integer(not TurnOn) shl Bit); | |
| end; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #define ALIGN_OF(t) ((int)(sizeof(struct{char c; t x;}) - sizeof(t))) | |
| int main() | |
| { | |
| printf("char: %d\n", ALIGN_OF(char)); | |
| printf("short: %d\n", ALIGN_OF(short)); | |
| printf("int: %d\n", ALIGN_OF(int)); | |
| printf("long: %d\n", ALIGN_OF(long)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var _, D; | |
| (_ = function(){return this["trela".match(/\w/g)["reverse"]().join("")];})[false] = "jonas"; | |
| _()(_[ (_(_)===D )]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Increment{ | |
| constructor(value) { | |
| this.current = +value || 0; | |
| }; | |
| [Symbol.toPrimitive]() { | |
| return ++this.current; | |
| } | |
| } | |
| var increment = new Increment(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function print(o){ | |
| var | |
| m = o.length >> 1, | |
| r = m, | |
| c = m + 1; | |
| p = function(){ | |
| console.log(o[r][c]); | |
| }, | |
| left = function(i){ | |
| for(; c > i; p(--c)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //+ Jonas Raoni Soares Silva | |
| //@ http://raoni.org | |
| // Iteration 3: manually minified xD | |
| const sum = (...args) => ((v, r = sum.bind(this, v)) => (r[Symbol.toPrimitive] = () => v, r))(args.reduce((a, b) => a + b, 0)); | |
| // Iteration 2: supports sum(1,2,3) | |
| const sum = (...args) => { | |
| const operation = (...args) => args.reduce((a, b) => a + b, 0); | |
| let current = operation(...args); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Backup = { | |
| shell: WScript.CreateObject("WScript.Shell"), | |
| base: "C:/BACKUP/", | |
| username: "USERNAME", | |
| hostname: "HOST", | |
| password: "PASSWORD", | |
| type: { | |
| postgreSQL: function(){ | |
| var shell = Backup.shell; | |
| var path = "c:/program files/postgresql/9.6/bin/"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Text.RegularExpressions; | |
| namespace Raoni { | |
| public static class Utils { | |
| private string queryLimit(string query, uint limit, uint? offset) { | |
| if(limit > 0) { | |
| offset = offset == null ? 0 : offset; | |
| if(offset < 0) | |
| throw new Exception("LIMIT argument offset=" + offset + " is not valid"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT | |
| C.Table_Name, | |
| C.Constraint_Name, | |
| C.Constraint_Columns | |
| FROM | |
| ( | |
| SELECT | |
| object_name(i.object_id) table_name, i.name index_name, | |
| MAX(CASE index_column_id when 1 THEN col_name(ic.object_id,ic.column_id) ELSE '' END) + | |
| MAX(CASE index_column_id when 2 THEN col_name(ic.object_id,ic.column_id) ELSE '' END) + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- find missing indexes | |
| SELECT | |
| conrelid::regclass, conname, reltuples::bigint | |
| FROM | |
| pg_constraint | |
| JOIN pg_class | |
| ON conrelid = pg_class.oid | |
| WHERE | |
| contype = 'f' | |
| AND NOT EXISTS ( |
OlderNewer