text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_prefix|>function matrixClone(matrix, defaultValue) {
return matrix.map((row) => {
return defaultValue === undefined
? row.slice(0)
: Array(row.length).fill(defaultValue);
});
}
const deepEqual = require('./deepEqual');
// Test clone.
const a = [
[1, 2],
[1, 4],
];
console.log(
deepEqu<... | fim | yangshun/tech-interview-handbook | javascript |
<|fim_suffix|>]),
[
[1, 1],
[2, 4],
],
),
);
console.log(
deepEqual(
matrixTranspose([
[1, 2, 3],
[4, 5, 6],
]),
[
[1, 4],
[2, 5],
[3, 6],
],
),
);
<|fim_prefix|>function matrixTranspose(matrix) {
return matrix[0].map((col, i) => matrix.map((row)... | fim | yangshun/tech-interview-handbook | javascript |
<|fim_suffix|>x[0].length;
const visited = matrix.map((row) => Array(row.length).fill(false));
function dfs(i, j) {
if (visited[i][j]) {
return;
}
visited[i][j] = true;
DIRECTIONS.forEach((dir) => {
const row = i + dir[0],
col = j + dir[1];
// Boundary check.
if (row ... | fim | yangshun/tech-interview-handbook | javascript |
<|fim_prefix|>function mergeSort(arr) {
if (arr.length < 2) {
// Arrays of length 0 or 1 are sorted by definition.
return arr;
}
const left = arr.slice(0, Math.floor(arr.length / 2));
const right = arr.slice(Math.floor(arr<|fim_suffix|>[j] < arr1[i]) {
merged.push(arr2[j]);
j++;
}
}
... | fim | yangshun/tech-interview-handbook | javascript |
<|fim_suffix|>treeEqual(node1.left, node2.left) &&
treeEqual(node1.right, node2.right)
);
}
<|fim_prefix|>function treeEqual(n<|fim_middle|>ode1, node2) {
if (!node1 && !node2) {
return true;
}
if (!node1 || !node2) {
return false;
}
return (
node1.val == node2.val &&
<|endoftext|> | fim | yangshun/tech-interview-handbook | javascript |
<|fim_prefix|>function treeMirror(node) {
if (!nod<|fim_suffix|>urn;
}
let temp = node.left;
node.left = node.right;
node.right = temp;
treeMirror(node.left);
treeMirror(node.right);
}
<|fim_middle|>e) {
ret<|endoftext|> | fim | yangshun/tech-interview-handbook | javascript |
<|fim_prefix|>def binary_search(arr, target):
left = 0;
right = len(arr) - 1
w<|fim_suffix|>arget:
return mid
elif arr[mid] < target:
left = mid + 1
else:
right = mid - 1
return -1
def bisect_left(arr, target):
"""Returns the leftmost position tha... | fim | yangshun/tech-interview-handbook | python |
<|fim_prefix|># For mapping a lowercase character to a prime number.
# Useful f<|fim_suffix|>n mul([primes[c] for c in string])
print(prime_value_of_string('abcde'))
<|fim_middle|>or checking whether two strings are anagram or permutations of each other.
primes = {
'a': 2, 'b': 3, 'c': 5, 'd': 7, 'e': 11, 'f': 13,... | fim | yangshun/tech-interview-handbook | python |
<|fim_suffix|>xt_j = (i + direction[0] + rows) % rows, (j + direction[1] + cols) % cols
dfs(next_i, next_j)
for i in range(rows):
for j in range(cols):
dfs(i, j)
graph_dfs([
[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12],
])
<|fim_prefix|>def graph_dfs(matrix):
rows, c... | fim | yangshun/tech-interview-handbook | python |
<|fim_prefix|>def graph_topo_sort(num_nodes, edges):
from collections import deque
nodes, order, queue = {}, [], deque()
for node_id in range(num_nodes):
nodes[node_id] = { 'in': 0, 'out': set() }
for node_id, pre_id in edges:
nodes[node_id]['in'] += 1
nodes[pre_id]['out'].add(no... | fim | yangshun/tech-interview-handbook | python |
<|fim_suffix|>heap[i]
i = parent_i
continue
break
def _bubble_down(heap, i):
startpos = i
newitem = heap[i]
left_i = 2 * i + 1
while left_i < len(heap):
# Pick the smaller of the L and R children
right_i = left_i + 1
if right_i < len(heap) and not... | fim | yangshun/tech-interview-handbook | python |
<|fim_suffix|>s] == char:
matched_s += 1
return matched_s == len(s)
<|fim_prefix|>def is_subsequence(s, t):
"""
:type s: str
:type t: str
:rtype: bool
"""
if len(s) > len(t):
return False
matched_s = 0
for char in t:
if matched_s < len(s) a<|fim_middle|>nd... | fim | yangshun/tech-interview-handbook | python |
<|fim_suffix|>])
linked_list = linked_list_delete_index(linked_list, 1)
print([node.value for node in linked_list_iter(linked_list)])
# Delete until empty
linked_list = linked_list_delete_index(linked_list, 0)
linked_list = linked_list_delete_index(linked_list, 0)
print([node.value for node in linked_list_iter(linked_... | fim | yangshun/tech-interview-handbook | python |
## QuickSelect -- Linear-time k-th order statistic
## (i.e. select the k-th smallest element in an unsorted array)
## https://en.wikipedia.org/wiki/Quickselect
def partition(array, start, end, pivot):
"""Partitions by a pivot value, which might not necessarily be in the array.
This variant is useful when you w... | fim | yangshun/tech-interview-handbook | python |
<|fim_prefix|>## Rabin-Karp Rolling Hash
## Implementation of: https://en.wikipedia.org/wiki/Rabin%E2%80%93Karp_algorithm#Hash_function_used
##
## This rolling hash function is useful when you need to compute the hash of successive substrings
## of text. E.g. note that going from 'abcd' to 'bcde', we drop the 'a' from ... | fim | yangshun/tech-interview-handbook | python |
<|fim_suffix|>al(node1.left, node2.left) and \
tree_equal(node1.right, node2.right)
<|fim_prefix|>def tree_equal(node1, node2):
if not node1 and not node2:
retu<|fim_middle|>rn True
if not node1 or not node2:
return False
return node1.val == node2.val and \
tree_equ<|endoftex... | fim | yangshun/tech-interview-handbook | python |
def tree_mirror(node):
if not node:
return
node.left, node.right = node.right, node.left
tree_mirror(node.left)
tree_mirror(node.right)
<|endoftext|> | fim | yangshun/tech-interview-handbook | python |
<|fim_suffix|> if curr_node.right:
stack.append(curr_node.right)
if curr_node.left:
stack.append(curr_node.left)
return result
def postorder_traversal(root):
"""
:type root: TreeNode
:rtype: List[int]
"""
if not root:
return []
result = []
stack ... | fim | yangshun/tech-interview-handbook | python |
<|fim_prefix|>class Trie(object):
def __init__(self):
"""
Initialize your data structure here.
"""
self.d = {}
def insert(self, word):
"""
Inserts a word into the trie.
:type word: str
:rtype: void
"""
curr = self.d
for cha... | fim | yangshun/tech-interview-handbook | python |
<|fim_prefix|>## Union-Find data structure
##<|fim_suffix|>:
root = parents[root]
# Flatten tree
while parents[p] != p:
parents[p], p = root, parents[p]
return root
def union(parents, p, q):
'''Average: O(log n)'''
p = find_root(parents, p)
q = find_root(parents, q)
# Link t... | fim | yangshun/tech-interview-handbook | python |
<|fim_suffix|>L = SOURCE_HOST + url.pathname + url.search;
// Fetch the content from the new domain
return await fetch(newURL, request);
}
<|fim_prefix|>const SOURCE_HOST = 'https://grind75.pages.dev';
export async function onRequest(context) {
const { request } = context;
// Define the original and target pa... | fim | yangshun/tech-interview-handbook | javascript |
<|fim_suffix|>,
],
},
{
'Algorithms study cheatsheets': [
'algorithms/study-cheatsheet',
{
type: 'category',
label: 'Basics',
collapsible: false,
items: [
'algorithms/array',
'algorithms/string',
'algorithms/... | fim | yangshun/tech-interview-handbook | javascript |
<|fim_suffix|> => {
const timer = setTimeout(() => {
setCounter((counter) => counter + 1);
}, AD_REFRESH_RATE);
return () => clearTimeout(timer);
}, [counter]);
// Because the SSR and client output can differ and hydration doesn't patch attribute differences,
// we'll render this on the browse... | fim | yangshun/tech-interview-handbook | javascript |
<|fim_suffix|>d look out for during my
applicaion. It has helped me so much in many stages of my application.
My personal favorite is the best algorithm practice questions, which is
helpful in the future if I want to switch jobs.
<br />
<br />
With the help of this handbo... | fim | yangshun/tech-interview-handbook | javascript |
<|fim_prefix|>import React from 'react';
import clsx from 'clsx';
import Layout from '@theme/Layout';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import Link from '@docusaurus/Link';
import useBaseUrl from '@docusaurus/useBaseUrl';
import styles from './styles.module.css';
import successStorie... | fim | yangshun/tech-interview-handbook | javascript |
<|fim_prefix|>import React from 'react';
import clsx from 'clsx';
import { ThemeClassNames } from <|fim_suffix|>ng
*/
function useSyntheticTitle() {
const { metadata, frontMatter, contentTitle } = useDoc();
const shouldRender =
!frontMatter.hide_title && typeof contentTitle === 'undefined';
if (!shouldRender)... | fim | yangshun/tech-interview-handbook | javascript |
<|fim_suffix|>;
import SidebarAd from '../../../components/SidebarAd';
/**
* Decide if the toc should be rendered, on mobile or desktop viewports
*/
function useDocTOC() {
const { frontMatter, toc } = useDoc();
const windowSize = useWindowSize();
const hidden = frontMatter.hide_table_of_contents;
const canRe... | fim | yangshun/tech-interview-handbook | javascript |
<|fim_prefix|>import React from 'react';
import type { P<|fim_suffix|>nt<typeof DocSidebarMobile>;
export default _default;
<|fim_middle|>rops } from '@theme/DocSidebar/Mobile';
declare function DocSidebarMobile(props: Props): JSX.Element;
declare const _default: React.MemoExoticCompone<|endoftext|> | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>import React from 'react';
import clsx from 'clsx';
import {
<|fim_suffix|>temClick={(item) => {
// Mobile sidebar should only be closed if the category has a link
if (item.type === 'category' && item.href) {
mobileSidebar.toggle();
}
if (item.type === ... | fim | yangshun/tech-interview-handbook | javascript |
<|fim_prefix|>import React from 'react';
import clsx from 'clsx';
import TOC<|fim_suffix|>hin-scrollbar', className)}>
<div className="margin--md">
<SidebarAd position="table_of_contents" />
</div>
<h3
className="padding-left--md padding-top--md margin-bottom--none"
style={{
... | fim | yangshun/tech-interview-handbook | javascript |
<|fim_prefix|>const defaultThe<|fim_suffix|>ar', ...defaultTheme.fontFamily.sans],
},
colors: {
primary: colors.indigo,
danger: colors.rose,
info: colors.sky,
success: colors.emerald,
warning: colors.amber,
},
},
},
plugins: [
require('@tailwindcss/a... | fim | yangshun/tech-interview-handbook | javascript |
<|fim_suffix|>ror',
'prefer-destructuring': [
'error',
{
object: true,
},
],
radix: 'error',
'react/button-has-type': 'error',
'react/display-name': 'off',
'react/exhaustive-deps': 'off',
'react/jsx-boolean-value': ['error', 'always'],
'r... | fim | yangshun/tech-interview-handbook | typescript |
<|fim_prefix|>/*
* Copyright (c) 2009 Marcel Bokhorst <marcel@bokhorst.biz>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS... | fim | yarrick/iodine | c |
<|fim_suffix|>size_t *buflen, const char *str,
size_t slen)
{
unsigned char *ustr = (unsigned char *) str;
unsigned char *ubuf = (unsigned char *) buf;
int iout = 0; /* to-be-filled output byte */
int iin = 0; /* next input char to use in decoding */
base128_reverse_init();
/* Note: Don't bother to optimiz... | fim | yarrick/iodine | c |
<|fim_suffix|> used up, iin=6 */
iout++;
if (iout >= *buflen || iin + 1 >= slen ||
str[iin] == '\0' || str[iin + 1] == '\0')
break;
ubuf[iout] = ((REV32(str[iin]) & 0x07) << 5) |
((REV32(str[iin + 1]) & 0x1f));
iin += 2; /* 6,7 used up, iin=8 */
iout++;
}
ubuf[iout] = '\0';
return io... | fim | yarrick/iodine | c |
<|fim_prefix|>/*
* Copyright (c) 2006-2014 Erik Ekman <yarrick@kryo.se>,
* 2006-2009 Bjorn Andersson <flex@kryo.se>
* Mostly rewritten 2009 J.A.Bezemer@opensourcepartners.nl
*
* Permission to use, copy, modify, and/or distribute this software for any<|fim_suffix|> ((REV64(str[iin + 1]) & 0x30) >> 4);
iin++; ... | fim | yarrick/iodine | c |
<|fim_prefix|>/*
* Copyright (c) 2006-2014 Erik Ekman <yarrick@kryo.se>,
* 2006-2009 Bjorn Andersson <flex@kryo.se>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice ap... | fim | yarrick/iodine | c |
<|fim_suffix|>set_lazymode(int lazy_mode);
void client_set_hostname_maxlen(int i);
int client_handshake(int dns_fd, int raw_mode, int autodetect_frag_size,
int fragsize);
int client_tunnel(int tun_fd, int dns_fd);
#endif
<|fim_prefix|>/*
* Copyright (c) 2006-2014 Erik Ekman <yarrick@kryo.se>,
* 2006-2009 Bjo... | fim | yarrick/iodine | c |
/* Copyright (c) 2006-2014 Erik Ekman <yarrick@kryo.se>,
* 2006-2009 Bjorn Andersson <flex@kryo.se>
* Copyright (c) 2007 Albert Lee <trisk@acm.jhu.edu>.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright... | fim | yarrick/iodine | c |
<|fim_prefix|>/*
* Copyright (c) 2006-2015 Erik Ekman <yarrick@kryo.se>,
* 2006-2009 Bjorn Andersson <flex@kryo.se>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice ap... | fim | yarrick/iodine | c |
<|fim_prefix|>/*
* Copyright (c) 2006-2014 Erik Ekman <yarrick@kryo.se>,
* 2006-2009 Bjorn Andersson <flex@kryo.se>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice ap... | fim | yarrick/iodine | c |
<|fim_suffix|>ns_encode_nxdomain(char *buf, size_t buflen, struct query *q, const char *zone);
unsigned short dns_get_id(char *packet, size_t packetlen);
int dns_decode(char *, size_t, struct query *, qr_t, char *, size_t);
#endif /* _DNS_H_ */
<|fim_prefix|>/*
* Copyright (c) 2006-2014 Erik Ekman <yarrick@kryo.se>,
... | fim | yarrick/iodine | c |
<|fim_suffix|>re topdomain + 2 safety */
if (!encoder->places_dots)
space -= (space / 57); /* space for dots */
memset(buf, 0, buflen);
encoder->encode(buf, &space, data, datalen);
if (!encoder->places_dots)
inline_dotify(buf, buflen);
b = buf;
b += strlen(buf);
/* move b back one step to see if the do... | fim | yarrick/iodine | c |
<|fim_suffix|>denbau.de>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRA... | fim | yarrick/iodine | c |
<|fim_prefix|>/*
* Copyright (c) 2008-2014 Erik Ekman <yarrick@kryo.se>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PRO... | fim | yarrick/iodine | c |
<|fim_suffix|>
#define FW_QUERY_CACHE_SIZE 16
struct fw_query {
struct sockaddr_storage addr;
int addrlen;
unsigned short id;
};
void fw_query_init(void);
void fw_query_put(struct fw_query *fw_query);
void fw_query_get(unsigned short query_id, struct fw_query **fw_query);
#endif /*__FW_QUERY_H__*/
<|fim_prefix|>... | fim | yarrick/iodine | c |
<|fim_suffix|>ids) < 0 || setgid(pw->pw_gid) < 0 || setuid(pw->pw_uid) < 0) {
warnx("Could not switch to user %s!\n", username);
usage();
/* NOTREACHED */
}
#endif
}
if (context != NULL)
do_setcon(context);
client_tunnel(tun_fd, dns_fd);
cleanup2:
close_dns(dns_fd);
close_tun(tun_fd);
cleanup1:
r... | fim | yarrick/iodine | c |
<|fim_prefix|>/*
* Copyright (c) 2006-2015 Erik Ekman <yarrick@kryo.se>,
* 2006-2009 Bjorn Andersson <flex@kryo.se>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice ap... | fim | yarrick/iodine | c |
<|fim_suffix|>TY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH ... | fim | yarrick/iodine | c |
<|fim_suffix|>, int);
#endif
<|fim_prefix|>/*
* Copyright (c) 2006-2014 Erik Ekman <yarrick@kryo.se>,
* 2006-2009 Bjorn Andersson <flex@kryo.se>
*
* Permission to use, copy, modify, and/or distribute this software for any
* p<|fim_middle|>urpose with or without fee is hereby granted, provided that the above
* c... | fim | yarrick/iodine | c |
<|fim_prefix|>/*
Copyright (C) 1999, 2000, 2002 Aladdin Enterprises. All rights reserved.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use th... | fim | yarrick/iodine | c |
<|fim_prefix|>/*
Copyright (C) 1999, 2002 Aladdin Enterprises. All rights reserved.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this sof... | fim | yarrick/iodine | c |
<|fim_suffix|>
if (tocopy > srcremain)
return 0; /* illegal, better have nothing */
if (tocopy > dstremain)
return 0; /* doesn't fit, better have nothing */
memcpy(dst, *src, tocopy);
dst += tocopy;
(*src) += tocopy;
srcremain -= tocopy;
dstremain -= tocopy;
dstused += tocopy;
}
return dstused... | fim | yarrick/iodine | c |
/*
* Copyright (c) 2006-2014 Erik Ekman <yarrick@kryo.se>,
* 2006-2009 Bjorn Andersson <flex@kryo.se>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all co... | fim | yarrick/iodine | c |
<|fim_suffix|>e, ip);
snprintf(cmdline, sizeof(cmdline), "netsh interface ip set address \"%s\" static %s %s",
if_name, ip, inet_ntoa(net));
return system(cmdline);
#endif
}
int
tun_setmtu(const unsigned mtu)
{
#ifndef WINDOWS32
char cmdline[512];
if (mtu > 200 && mtu <= 1500) {
snprintf(cmdline, sizeof(cmdli... | fim | yarrick/iodine | c |
<|fim_suffix|>NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMA... | fim | yarrick/iodine | c |
<|fim_suffix|>struct in_addr ip;
ip.s_addr = users[0].tun_ip;
return strdup(inet_ntoa(ip));
}
int find_user_by_ip(uint32_t ip)
{
int ret;
int i;
ret = -1;
for (i = 0; i < usercount; i++) {
if (users[i].active &&
users[i].authenticated &&
!users[i].disabled &&
users[i].last_pkt + 60 > time(NULL) &&
... | fim | yarrick/iodine | c |
<|fim_suffix|>id);
int find_available_user(void);
void user_switch_codec(int userid, const struct encoder *enc);
void user_set_conn_type(int userid, enum connection c);
#endif
<|fim_prefix|>/*
* Copyright (c) 2006-2014 Erik Ekman <yarrick@kryo.se>,
* 2006-2009 Bjorn Andersson <flex@kryo.se>
*
* Permission to use, ... | fim | yarrick/iodine | c |
<|fim_prefix|>/*
* Copyright (c) 2006-2014 Erik Ekman <yarrick@kryo.se>,
* 2006-2009 Bjorn Andersson <flex@kryo.se>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice ap... | fim | yarrick/iodine | c |
<|fim_prefix|>/*
* Copyright (c) 2006-2014 Erik Ekman <yarrick@kryo.se>,
* 2006-2009 Bjorn Andersson <flex@kryo.se>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice ap... | fim | yarrick/iodine | c |
<|fim_suffix|> protocol
It is usually equal to the latest iodine version number */
#define PROTOCOL_VERSION 0x00000502
#endif /* _VERSION_H_ */
<|fim_prefix|>/*
* Copyright (c) 2006-2014 Erik Ekman <yarrick@kryo.se>,
* 2006-2009 Bjorn Andersson <flex@kryo.se>
*
* Permission to use, copy, modify, and/or distrib... | fim | yarrick/iodine | c |
<|fim_suffix|> DNS_TYPE_SOA
#define T_SRV DNS_TYPE_SRV
#define C_IN 1
#define FORMERR 1
#define SERVFAIL 2
#define NXDOMAIN 3
#define NOTIMP 4
#define REFUSED 5
#define sleep(seconds) Sleep((seconds)*1000)
typedef struct {
unsigned id :16; /* query identification number */
/* fields in third byte */
unsigned ... | fim | yarrick/iodine | c |
<|fim_suffix|>; i < rawlen; i++) {
ck_assert(rawbuf[i] == 'A');
}
}
END_TEST
TCase *
test_base32_create_tests(void)
{
TCase *tc;
tc = tcase_create("Base32");
tcase_add_loop_test(tc, test_base32_encode, 0, TUPLES);
tcase_add_loop_test(tc, test_base32_decode, 0, TUPLES);
tcase_add_test(tc, test_base32_5to8_8to5... | fim | yarrick/iodine | c |
<|fim_prefix|>/*
* Copyright (c) 2006-2014 Erik Ekman <yarrick@kryo.se>,
* 2006-2009 Bjorn Andersson <flex@kryo.se>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice ap... | fim | yarrick/iodine | c |
<|fim_prefix|>/*
* Copyright (c) 2006-2014 Erik Ekman <yarrick@kryo.se>,
* 2006-2009 Bjorn Andersson <flex@kryo.se>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice ap... | fim | yarrick/iodine | c |
<|fim_suffix|>\x72\x79\x6F\x02\x73\x65\x00\x00"
"\x0A\x00\x01\x00\x00\x29\x10\x00\x00\x00\x80\x00\x00\x00";
static char answer_packet[] =
"\x05\x39\x84\x00\x00\x01\x00\x01\x00\x00\x00\x00\x05\x73\x69\x6C\x6C"
"\x79\x04\x68\x6F\x73\x74\x02\x6F\x66\x06\x69\x6F\x64\x69\x6E\x65\x04"
"\x63\x6F\x64\x65\x04\x6B\x72\x79\x... | fim | yarrick/iodine | c |
/*
* Copyright (c) 2006-2014 Erik Ekman <yarrick@kryo.se>,
* 2006-2009 Bjorn Andersson <flex@kryo.se>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all co... | fim | yarrick/iodine | c |
<|fim_suffix|>48A);
q.addrlen++;
q.id++;
fw_query_put(&q);
/* but now it is overwritten */
fw_query_get(0x848A, &qp);
ck_assert(qp == NULL);
}
END_TEST
TCase *
test_fw_query_create_tests(void)
{
TCase *tc;
tc = tcase_create("Forwarded query");
tcase_add_test(tc, test_fw_query_simple);
tcase_add_test(tc, t... | fim | yarrick/iodine | c |
<|fim_prefix|>/*
* Copyright (c) 2006-2014 Erik Ekman <yarrick@kryo.se>,
* 2006-2009 Bjorn Andersson <flex@kryo.se>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice ap... | fim | yarrick/iodine | c |
<|fim_prefix|>/*
* Copyright (c) 2006-2014 Erik Ekman <yarrick@kryo.se>,
* 2006-2009 Bjorn Andersson <flex@kryo.se>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice ap... | fim | yarrick/iodine | c |
<|fim_suffix|>_add_tcase(iodine, test);
test = test_common_create_tests();
suite_add_tcase(iodine, test);
test = test_dns_create_tests();
suite_add_tcase(iodine, test);
test = test_encoding_create_tests();
suite_add_tcase(iodine, test);
test = test_read_create_tests();
suite_add_tcase(iodine, test);
tes... | fim | yarrick/iodine | c |
<|fim_suffix|>&& \
((CHECK_MINOR_VERSION == 9 && CHECK_MICRO_VERSION < 2) || \
(CHECK_MINOR_VERSION < 9)))
#define tcase_set_timeout(...)
#endif
#endif
<|fim_prefix|>/*
* Copyright (c) 2006-2014 Erik Ekman <yarrick@kryo.se>,
* 2006-2009 Bjorn Andersson <flex@kryo.se>
*
* Permission to use, copy, modify, and/or ... | fim | yarrick/iodine | c |
<|fim_prefix|>/*
* Copyright (c) 2006-2014 Erik Ekman <yarrick@kryo.se>,
* 2006-2009 Bjorn Andersson <flex@kryo.se>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice ap... | fim | yarrick/iodine | c |
<|fim_prefix|>namespace FVim
open Avalonia
open Avalonia.Controls
open Avalonia.Controls.Templates
open Avalonia.Markup.Xaml
open System
open log
type ViewLocator() =
interface IDataTemplat<|fim_suffix|>ide this.Initialize() =
AvaloniaXamlLoader.Load this
<|fim_middle|>e with
member this.Build(d... | fim | yatli/fvim | fsharp |
<|fim_suffix|>n 3. run\nThank you for your cooperation."
member __.StackTrace = "foo\nbar\nbaz"
<|fim_prefix|>namespace FVim
type CrashReportSampleData() =
member __.MainMessage = "Some error: some detailed error message.\nThis error is so bad that we have to bail out."
member __.TipMessage = "\n\nIn c... | fim | yatli/fvim | fsharp |
<|fim_suffix|>
member this.BufferWidth = 400.0
member this.BufferHeight = 300.0
<|fim_prefix|>namespace FVim
open Avalonia.Media
open Avalonia.Controls
open Ava<|fim_middle|>lonia.Media.Imaging
type GridSampleData() =
member this.BackgroundBrush = Brushes.DarkGray<|endoftext|> | fim | yatli/fvim | fsharp |
<|fim_suffix|>ember __.MainGrid = GridSampleData()
<|fim_prefix|>namespace FVim
open Aval<|fim_middle|>onia.Controls
type MainWindowSampleData() =
member __.Title = "FVim - Test.txt"
member __.UseCustomTitleBar = true
member __.CustomTitleBarHeight = GridLength 26.0
member __.BorderSize = GridLength ... | fim | yatli/fvim | fsharp |
<|fim_suffix|>ackground = Brushes.DarkSlateBlue
member __.NormalForeground = Brushes.White
member __.HoverBackground = Brushes.MediumVioletRed
member __.HoverForeground = Brushes.Blue
member __.SelectBackground = Brushes.Yellow
member __.SelectForeground = Brushes.Green
member __.FontFamily = "C... | fim | yatli/fvim | fsharp |
<|fim_prefix|>module FVim.Program
open System
open System.IO
open System.Threading
open Avalonia
open Avalonia.ReactiveUI
open Avalonia.Controls.ApplicationLifetimes
open def
open getopt
open common
open shell
open daemon
open FVim.ui
let inline trace x = FVim.log.trace "main" x
// Avalonia configuration, don't r... | fim | yatli/fvim | fsharp |
<|fim_prefix|>namespace FVim
open def
open log
open common
open Avalonia.Media.Imaging
open Avalonia.Platform
open Avalonia
module CompletionItemHelper =
// Taken from coc.nvim/src/languages.ts
type CompletionItemKind =
| Text //'v'],
| Method //'f'],
| Function //'f'],
| Cons... | fim | yatli/fvim | fsharp |
<|fim_prefix|>namespace FVim
open common
ope<|fim_suffix|> ex.StackTrace
member __.TipMessage =
let tip =
match ex.Message.Trim() with
| "The system cannot find the file specified."
| "No such file or directory" -> "Tip: check your neovim installation. `nvim` is ... | fim | yatli/fvim | fsharp |
namespace FVim
open Avalonia.Media
open FVim.def
open FVim.common
type CursorViewModel(cursorMode: int option) =
inherit ViewModelBase(None, None, Some 1.0, Some 1.0)
member val enabled: bool = true with get,set
member val focused: bool = false with get,set // true if a cursorGoto message is... | fim | yatli/fvim | fsharp |
<|fim_suffix|>talAlignment = m_bgimg_halign
member __.BackgroundImageVAlign with get(): VerticalAlignment = m_bgimg_valign
member __.BackgroundImageW with get(): float = m_bgimg_w
member __.BackgroundImageH with get(): float = m_bgimg_h
member __.BackgroundImageOpacity with get(): float = m_bgimg_opacit... | fim | yatli/fvim | fsharp |
<|fim_suffix|> let _, _, vm, r, c, _ = this.FindTargetVm y x
let dx, dy = e.Delta.X, e.Delta.Y
raiseInputEvent vm.GridId (InputEvent.MouseWheel(e.KeyModifiers, r, c, dx, dy)) e
member __.OnTextInput (e: TextInputEventArgs) =
raiseInputEvent _gridid (InputEvent.TextInput(e.... | fim | yatli/fvim | fsharp |
<|fim_suffix|>ght > desiredSizeVec.Y / 3.0 || r_se.Height > r_ne.Height then
trace "r_e: choose region SE: %A" r_se
r_se
else
trace "r_e: choose region NE: %A" r_ne
r_ne
let r_w =
if r_sw.Height > desiredSizeVec.Y / 3.0 || r_sw.Height > r_nw.... | fim | yatli/fvim | fsharp |
<|fim_prefix|>namespace FVim
open common
open ReactiveUI
open Avalonia.Media
open Avalonia
#nowarn "0025"
type ThemableViewModelBase(x, y, w, h) as this =
inherit ViewModelBase(x, y, w, h)
static let mutable s_normalFg: IBrush = Brushes.Black :> IBrush
static let mutable s_normalBg: IBrush = Brushes.... | fim | yatli/fvim | fsharp |
<|fim_prefix|>namespace FVim
open ReactiveUI
t<|fim_suffix|>with get() = m_title
and set(v) = ignore <| this.RaiseAndSetIfChanged(&m_title, v)
<|fim_middle|>ype TitleBarViewModel() =
inherit ThemableViewModelBase()
let mutable m_onright = true
let mutable m_title = ""
member this.ButtonsOnR... | fim | yatli/fvim | fsharp |
<|fim_suffix|>ember this.X
with get() : float = m_x
and set(v) = ignore <| this.RaiseAndSetIfChanged(&m_x, v, "X")
member this.Y
with get() : float = m_y
and set(v) = ignore <| this.RaiseAndSetIfChanged(&m_y, v, "Y")
member this.Height
with get(): float = m_h
... | fim | yatli/fvim | fsharp |
<|fim_suffix|>ad(this)
<|fim_prefix|>namespace FVim
open System.Windows.Input
open ReactiveUI
open Avalonia.Markup.Xaml
open Avalonia.Controls
open Avalonia
open Avalonia.Input
open Avalonia.Interactivity
open FVim.log
type CompletionItem() as this =
inherit ViewBase<CompletionItemV<|fim_middle|>iewModel>()
... | fim | yatli/fvim | fsharp |
<|fim_suffix|>mlLoader.Load(this)
<|fim_prefix|>namespace FVim
open ui
open log
open common
open Avalonia.Markup.Xaml
ope<|fim_middle|>n Avalonia.Controls
type CrashReport() as this =
inherit Window()
do
AvaloniaXa<|endoftext|> | fim | yatli/fvim | fsharp |
namespace FVim
open log
open ui
open common
open def
open model
open Avalonia
open Avalonia.Animation
open Avalonia.Controls
open Avalonia.Data
open Avalonia.Markup.Xaml
open Avalonia.Media
open Avalonia.Media.Imaging
open Avalonia.Skia
open Avalonia.Threading
open Avalonia.VisualTree
open System
open System.Collect... | fim | yatli/fvim | fsharp |
namespace FVim
open def
open log
open common
open ui
open ReactiveUI
open Avalonia.Markup.Xaml
open Avalonia.Controls
open Avalonia.Input
open Avalonia
open Avalonia.Data
open Avalonia.ReactiveUI
open System.Runtime.InteropServices
open Avalonia.Rendering
open Avalonia.Interactivity
open Avalonia.VisualTree
open Av... | fim | yatli/fvim | fsharp |
<|fim_suffix|>dth, grid_fb.Size.Height)
ctx.DrawImage(grid_fb, src_rect, tgt_rect, BitmapInterpolationMode.LowQuality)
for vm in _drawVMs do
// do not draw gadgets for the root grid / message / floating windows (borders only)
if vm.GridId <> 1 && not vm.AboveGadgets then
drawGadget... | fim | yatli/fvim | fsharp |
<|fim_suffix|>u() as this =
inherit ViewBase<PopupMenuViewModel>()
let relayToParent (e: #Avalonia.Interactivity.RoutedEventArgs) =
if this.Parent <> null then
trace "PopupMenu" "relay to parent"
this.Parent.Focus()
do
AvaloniaXamlLoader.Load(this)
let lst =... | fim | yatli/fvim | fsharp |
<|fim_prefix|>namespace FVim
open Avalonia.Markup.Xaml
open Avalonia.Vis<|fim_suffix|>lTree
open Avalonia.Controls
open Avalonia
open Avalonia.Rendering
type TitleBar() as this =
inherit ViewBase<TitleBarViewModel>()
static let TitleProperty = AvaloniaProperty.Register<TitleBar, string>("Title")
static ... | fim | yatli/fvim | fsharp |
<|fim_prefix|>namespace FVim
open ReactiveUI
open Avalonia
open Avalonia.Controls
open Avalonia.Data
open FSharp.Control.Reactive
type ViewBase< 'TViewModel when 'TViewModel :> ViewModelBase and 'TViewModel: not struct>() as this =
i<|fim_suffix|>erTick")
static let ViewModelProperty = AvaloniaProperty.Regist... | fim | yatli/fvim | fsharp |
<|fim_prefix|>module FVim.common
open System.Threading.Tasks
open System
open System.Diagnostics
open System.Buffers
open Avalonia.Media
let mkparams1 (t1: 'T1) = [| box t1 |]
let mkparams2 (t1: 'T1) (t2: 'T2) = [| box t1; box t2 |]
let mkparams3... | fim | yatli/fvim | fsharp |
<|fim_suffix|>me composition, Some customTitleBar, Some noTitleBar))
let wss = dict.Add(cwd, ws)
let defaults = ConfigObject.Default(def_w, def_h)
let cfg = ConfigObject.Root(wss |> Map.toArray |> Array.map snd, cfg.Logging, Some defaults)
try File.WriteAllText(configfile, cfg.ToString())
with _ ->... | fim | yatli/fvim | fsharp |
<|fim_suffix|>// Something is completed, let's investigate why
if not session.proc.HasExited then
// the NeoVim server is still up and running
sessions.[session.id] <- { session with server = None }
trace "Session %d detached" session.id
return ()
}
let serve nvim stderrenc (pipe: NamedPipe... | fim | yatli/fvim | fsharp |
<|fim_prefix|>module FVim.def
open log
open common
open Avalonia.Media
open System
open System.Threading.Tasks
open SkiaSharp
open Avalonia.Layout
let inline private trace fmt = trace "def" fmt
[<Struct>]
type Request =
{
method: string
parameters: obj[]
}
type Response = Result<obj, ... | fim | yatli/fvim | fsharp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.