This file contains 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
# The solution is based upon this answer: | |
# https://stackoverflow.com/questions/19050461/cmake-add-target-for-invoking-clang-analyzer | |
function(add_clang_static_analysis target) | |
get_target_property(SRCs ${target} SOURCES) | |
add_library(${target}_analyze OBJECT EXCLUDE_FROM_ALL ${SRCs}) | |
if (MSVC) | |
list(APPEND ANALYZER_OPTIONS --analyze) | |
list(APPEND ANALYZER_OPTIONS "SHELL:/clang:-Xanalyzer /clang:-analyzer-opt-analyze-headers") | |
list(APPEND ANALYZER_OPTIONS "SHELL:/clang:-Xanalyzer /clang:-analyzer-output=html") | |
# see output in <build/<file>.plist directories |
This file contains 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> | |
#include <map> | |
#include <string> | |
#include <sstream> | |
#include <variant> | |
#include <vector> | |
struct JSONValue; | |
class JSONStringVisitor; | |
class JSONSerializer; |
This file contains 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
import bisect | |
# See Cormen et al, chapter 18 B-Trees. The implementation uses the 'bisect' module to implement | |
# a binary search (O(lg n)) through nodes. | |
def main(): | |
def allocme(): | |
nonlocal blocks | |
idx = len(blocks) | |
blocks.append(None) |
This file contains 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
import heapq | |
def main(): | |
freqmap = {'a':45, 'b':13, 'c':12, 'd':16, 'e':9, 'f':5} | |
char_to_code = huffman(freqmap) | |
print(char_to_code) | |
print(invert_dictionary(char_to_code)) | |
print() | |
# see https://en.wikipedia.org/wiki/Letter_frequency#Relative_frequencies_of_letters_in_other_languages |
This file contains 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
package psamolysov.algo.intro.maxsubarray; | |
import java.util.LinkedHashMap; | |
import java.util.Map; | |
public class LongestLinearSubstringer { | |
public static String findLongestKCharSubstring(String str, int k) { | |
if (str == null || str.length() < k) { | |
return str; |
This file contains 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
#Conditionally import wlstModule only when script is executed with jython | |
if __name__ == '__main__': | |
from wlstModule import *#@UnusedWildImport | |
def configureCluster(clusterName, isUnicast): | |
cluster = getMBean('/Clusters/' + clusterName) | |
if cluster == None: | |
print 'Creating cluster ' + clusterName | |
cluster = create(clusterName, 'Cluster') |