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 <iostream> | |
| // find the index of an element in a sorted array | |
| // return index if found, or -1 if not present | |
| int findIndex(int* array, int offset, int sizeOfArray, int value) | |
| { | |
| if (sizeOfArray == 1) | |
| { | |
| if (array[offset] == value) | |
| return offset; |
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
| create table test_text_replace(c1 varchar(100)); | |
| insert into test_text_replace(c1) values ('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam at elit velit, eget auctor urna nullam.'); | |
| update test_text_replace set c1 = regexp_replace(c1, 'Lorem', 'Dorem'); | |
| select * from test_text_replace; | |
| -- this returns-- Dorem ipsum dolor sit amet, David Levin elit. Nam at elit velit, eget auctor urna nullam. | |
| You can replace text wherever. For example : | |
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
| Warning: Some directories in /usr/local/share/man aren't writable. | |
| This can happen if you "sudo make install" software that isn't managed | |
| by Homebrew. If a brew tries to add locale information to one of these | |
| directories, then the install will fail during the link step. | |
| You should probably `chown` them: | |
| /usr/local/share/man/de | |
| /usr/local/share/man/de/man1 | |
| Warning: libiconv was detected in your PREFIX. |
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
| def query_to_csv(sql) | |
| db_result = @db.query(sql) | |
| csv = Array.new(db_result.columns) | |
| db_result.each {|row| csv.push(row.to_a)} | |
| csv | |
| 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
| sql = 'select * from account_status where account_status_id in ($1)' | |
| params = [1, 2] | |
| # obviously wrong. 2 params instead of 1 | |
| db.exec_params(sql, params) | |
| # PG::IndeterminateDatatype: ERROR: could not determine data type of parameter $2 | |
| params = [[1,2]] | |
| db.exec_params(sql, params) | |
| # PG::InvalidTextRepresentation: ERROR: invalid input syntax for integer: "[1, 2]" |
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
| CREATE FUNCTION f_now_immutable_date() | |
| RETURNS date AS | |
| $func$ | |
| SELECT CURRENT_DATE; | |
| $func$ LANGUAGE sql IMMUTABLE; |
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
| WITH btree_index_atts AS ( | |
| SELECT nspname, | |
| indexclass.relname as index_name, | |
| indexclass.reltuples, | |
| indexclass.relpages, | |
| indrelid, indexrelid, | |
| indexclass.relam, | |
| tableclass.relname as tablename, | |
| regexp_split_to_table(indkey::text, ' ')::smallint AS attnum, | |
| indexrelid as index_oid |
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
| mix ecto.drop | |
| Compiling 12 files (.ex) | |
| warning: unused alias FishLanded | |
| lib/fishing_spot/models/fish_landed.ex:3 | |
| == Compilation error on file lib/fishing_spot/repo.ex == | |
| ** (ArgumentError) missing :adapter configuration in config :fishing_spot, FishingSpot.Repo | |
| lib/ecto/repo/supervisor.ex:37: Ecto.Repo.Supervisor.parse_config/2 | |
| lib/fishing_spot/repo.ex:2: (module) |
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 r.recording_id FROM userdata.recordings r | |
| LEFT OUTER JOIN recording_migrator_recordings_existing rmre ON (rmre.recording_id = r.recording_id) | |
| AND r.account_service_id = 1000 | |
| AND rmre.recording_id IS NULL; | |
| recording_id | |
| -------------- | |
| 1000 | |
| 10000 | |
| (2 rows) |
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
| defmodule HdapViewer.AuthTest do | |
| use HdapViewer.ConnCase | |
| alias HdapViewer.Auth | |
| setup %{conn: conn} do | |
| conn = | |
| conn | |
| |> bypass_through(HdaViewer.Router, :browser) | |
| |> get("/") |
OlderNewer