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
use std::{ | |
cell::{Ref, RefCell}, | |
collections::HashMap, | |
fmt::Debug, | |
rc::Rc, | |
}; | |
/// LRU cache | |
struct LRU { | |
cache: HashMap<String, Rc<RefCell<ListNode>>>, |
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
-- Install packer | |
local install_path = vim.fn.stdpath 'data' .. '/site/pack/packer/start/packer.nvim' | |
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then | |
vim.fn.execute('!git clone https://github.com/wbthomason/packer.nvim ' .. install_path) | |
end | |
vim.cmd [[ | |
augroup Packer | |
autocmd! |
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 TRY(a) ({ \ | |
void* retval = NULL; \ | |
if (a != NULL) { retval = a; } else { return retval; } \ | |
retval; \ | |
}) | |
int sum(int _a, int _b) { | |
int a = TRY(_a); |
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
const gen_map = (f, g) => function* (arg) { | |
for (const x of g(arg)) | |
yield f(x) | |
}; | |
const gen_filter = (f, g) => function* (arg) { | |
for (const x of g(arg)) | |
if (f(x)) | |
yield x | |
}; |
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
#[derive(Debug)] | |
pub struct Ar(Enum); | |
impl Serialize for Ar { | |
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | |
where | |
S: serde::Serializer, | |
{ | |
serializer.serialize_newtype_struct("Ar", &self.0) |
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
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; | |
export function withProps<InjectingProps extends {}>(injectingProps: InjectingProps) { | |
return function <ExtendedProps extends InjectingProps>(SourceComponent: React.ComponentType<ExtendedProps>) { | |
type WithPropsHocProps = Omit<ExtendedProps, keyof InjectingProps>; | |
class WithPropsHoc extends React.PureComponent<WithPropsHocProps> { | |
render() { | |
return ( | |
<SourceComponent {...this.props} {...injectingProps}> |