Skip to content

Instantly share code, notes, and snippets.

@alexeyr
alexeyr / WCharPtrToStdString.cpp
Created June 29, 2021 16:19
The proper way to use wcsrtombs to convert a const wchar_t* to an std::string (so far as I can tell)
#include <cstring>
#include <cwchar>
inline void ResetMbState(std::mbstate_t &state) {
// this is really the recommended way to zero-initialize an mbstate_t
std::memset(&state, 0, sizeof(std::mbstate_t));
}
inline std::string WCharPtrToString(const wchar_t *data) {
std::mbstate_t state;
// ==UserScript==
// @name Feedly Tweak - Open feed item in background by pressing 'v'
// @namespace http://micbase.com/feedly-tweak-open-item-background-tab-firefox
// @description Feedly Tweak - Open feed item in background by pressing 'v'
// @include http*://*feedly.com/*
// @grant GM_openInTab
// ==/UserScript==
var x;
var link;
@alexeyr
alexeyr / gist:7927253
Created December 12, 2013 12:28
IDEA 13 error
[4555822] ERROR - llij.ide.plugins.PluginManager - None.get
java.util.NoSuchElementException: None.get
at scala.None$.get(Option.scala:313)
at scala.None$.get(Option.scala:311)
at scala.Enumeration.withName(Enumeration.scala:132)
at org.jetbrains.plugins.scala.config.ScalaFacet.languageLevel(ScalaFacet.scala:102)
at org.jetbrains.plugins.scala.lang.languageLevel.ScalaLanguageLevel$$anonfun$getLanguageLevel$1.apply(ScalaLanguageLevel.scala:85)
at org.jetbrains.plugins.scala.lang.languageLevel.ScalaLanguageLevel$$anonfun$getLanguageLevel$1.apply(ScalaLanguageLevel.scala:85)
at scala.Option.map(Option.scala:145)
at org.jetbrains.plugins.scala.lang.languageLevel.ScalaLanguageLevel$.getLanguageLevel(ScalaLanguageLevel.scala:85)
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@alexeyr
alexeyr / gist:2488555
Created April 25, 2012 09:40
Segmentation fault in JD-Eclipse
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f4450121b9c, pid=24085, tid=139931868645120
#
# JRE version: 6.0_23-b23
# Java VM: OpenJDK 64-Bit Server VM (20.0-b11 mixed mode linux-amd64 compressed oops)
# Derivative: IcedTea6 1.11pre
# Distribution: Ubuntu 11.10, package 6b23~pre11-0ubuntu1.11.10.2
# Problematic frame:
@alexeyr
alexeyr / gist:1379293
Created November 19, 2011 20:07
Macro use case: type lambdas
Macro:
S ==> ST[S, A]
Convert to:
({type λ[S] = ST[S, A]})#λ
@alexeyr
alexeyr / sqlite3_drv.c
Created April 5, 2011 06:45
Weirdness
static void sql_exec_one_statement(
sqlite3_stmt *statement, async_sqlite3_command *async_command,
int *term_count_p, int *term_allocated_p, ErlDrvTermData **dataset_p) {
int column_count = sqlite3_column_count(statement);
int row_count = 0, next_row;
int base_term_count;
sqlite3_drv_t *drv = async_command->driver_data;
ptr_list **ptrs_p = &(async_command->ptrs);
ptr_list **binaries_p = &(async_command->binaries);
'WindowNode(MyWindow,List(GuiNode(composite,Some(aComposite),Map(),List())))'
is not equal to
'WindowNode(MyWindow,List(GuiNode(composite,Some(acomposite),Map(),List())))'
#!/bin/bash
...
CMD="$BINDIR/erlexec -boot $RUNNER_BASE_DIR/releases/$APP_VSN/$SCRIPT -embedded -config $RUNNER_ETC_DIR/app.config -args_file $RUNNER_ETC_DIR/vm.args -- ${1+"$@"}"
/*********************************************************************************
* The contents of this file are subject to the Mozilla Public License Version 1.1
* ("License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.mozilla.org/MPL/.
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* The Initial Developer of the Original Code is Howie Wang.