answer
stringlengths
15
1.25M
<?php $bbcode["code"] = array( 'callback' => 'bbcodeCodeHighlight', 'pre' => TRUE, ); $bbcode["source"] = array( 'callback' => 'bbcodeCodeHighlight', 'pre' => TRUE, ); function bbcodeCodeHighlight($dom, $contents, $arg) { // in <pre> style $contents = preg_replace('/^\n|\n$/', "", $contents); include_once("geshi.php"); if(!$arg) { $div = $dom->createElement('div'); $div->setAttribute('class', 'codeblock'); $div->appendChild($dom->createTextNode($contents)); return $div; } else { $language = $arg; $geshi = new GeSHi($contents, $language); $geshi->set_header_type(GESHI_HEADER_NONE); $geshi->enable_classes(); $geshi-><API key>(false); $code = str_replace("\n", "", $geshi->parse_code()); return markupToMarkup($dom, "<div class=\"codeblock geshi\">$code</div>"); } }
@font-face { font-family: 'Source Sans Pro'; font-style: normal; font-weight: 400; src: local('Source Sans Pro'), local('<API key>'), url(fonts/<API key>.otf) format('opentype'); } @font-face { font-family: 'Source Sans Pro'; font-style: normal; font-weight: 600; src: local('Source Sans Pro Semibold'), local('<API key>'), url(fonts/<API key>.otf) format('opentype'); } @font-face { font-family: 'Source Sans Pro'; font-style: normal; font-weight: 700; src: local('Source Sans Pro Bold'), local('SourceSansPro-Bold'), url(fonts/SourceSansPro-Bold.otf) format('opentype'); } @font-face { font-family: 'Source Sans Pro'; font-style: normal; font-weight: 900; src: local('Source Sans Pro Black'), local('SourceSansPro-Black'), url(fonts/SourceSansPro-Black.otf) format('opentype'); } body { font-family: 'Source Sans Pro', 'Helvetica Neue', 'Arial', sans-serif; line-height: 1.8em; color: #333935; background-color: #f5f5f5; font-size: 15px; margin: 0; } div, header, select, a { box-sizing: border-box; } .full-width { width: 100%; } .u-floatRight { float: right; } .u-floatLeft { float: left; } .u-textCenter { text-align: center; } .u-textRight { text-align: right; } .u-posFixed { position: fixed; } li { padding-bottom: 4px; } .nav { width: 100%; background-color: #fafafa; top: 0; } .wrap-width { width: 600px; margin: auto; padding: 0 20px; } .wrapper { min-width: 800px; margin-top: 60px; } .page-wrapper { max-width: 600px; margin: 60px auto 0; padding: 15px; } .sidebar { width: 25%; position: fixed; height: 100%; background-color: #f5f5f5; } .content { padding: 15px; margin-left: 25%; width: 75%; height: 100%; background-color: #fff; } .site-header { height: 60px; position: fixed; top: 0; width: 100%; font-size: 20px; z-index: 9; text-align: center; background: #fafafa; padding: 10px 0; border-bottom: 1px solid #e0e0e0; } .challenge-title { text-transform: capitalize; font-size: 19px; font-weight: 800; color: #4BABFF; line-height: 1; display: inline-block; } .pagination { position: absolute; top: 12px; right: 15px; } .list-of-challenges { list-style-type: none; margin: 0; padding: 0; } .list-of-challenges li { padding: 0; } .challenge-item { padding: 3px 10px; display: block; text-transform: capitalize; border-top: 3px solid transparent; border-left: 3px solid transparent; border-bottom: 3px solid transparent; } /* :after instead of :before cause it messes with text-transform */ .challenge-item:after { content: " "; float: left; width: 20px; display: inline-block; } .challenge-item.completed:after { content: " "; position: absolute; left: 10px; top: 4px; color: #fff; } .challenge-item.current .current-arrow { display: block; } .current-arrow { float: right; display: none; } .challenge-item.completed:hover { background-color: #1EA577; } .challenge-item.current { background-color: #ECFCE0; color: #456; margin-right: -3px; border-color: white; } .challenge-item.completed { position: relative; background-color: #22B784; color: #fff; padding-left: 30px; } .hand, .lang-select { padding: 4px 13px; border-radius: 3px; color: #0087ff; display: inline-block; } .hand { border: 1px solid #8cf; font-size: 26px; margin-left: 10px; } .lang-select { border-color: #8cf; position: absolute; height: 36px; width: 100px; margin: 5px 8px; top: 0; left: 0; appearance: none; -webkit-appearance: none; } .lang-select:after { content: ""; border: 5px solid transparent; border-top-color: #8cf; position: relative; left: 40px; top: 5px; pointer-events: none; display: inline-block; z-index: 10; } .hand:hover { border-color: transparent; background-color: #08f; color: #fff; } .challenge-name { text-transform: capitalize; font-weight: 900; color: #0087ff; } .filledblock { display: inline-block; padding: 4px 10px; font-weight: 900; } .filledblock:hover { background: #4BABFF; color: #fff; } .all-caps { font-size: 12px; text-transform: uppercase; } .site-header h2 { margin-top: 12px; } h1, h2, h3, h4, .toc { font-family: 'Source Sans Pro', 'Helvetica Neue', 'Arial', sans-serif; } .content h1, .content h2, .content h3, .content h4 { margin-top: 50px; } a { color: #0087ff; text-decoration: none; } a:hover { color: #4BABFF; } .toc li { margin-bottom: 10px; } .toc li a { font-weight: 700; } .toc { padding-left: 0; text-align: left; list-style-position: inside; } .toc .done:before { content: 'done!'; float: right; color: #aaa; text-decoration: none !important; } .toc .done a { text-decoration: line-through; } code, .outof { font-size: 0.9em; border: 1px solid #9DA6B3; padding: 4px 6px; border-radius: 2px; font-family: Liberation Mono, Monaco, Courier New, monospace; white-space: nowrap; } footer { border-top: 3px solid #0087ff; margin: 20px 0 0; padding: 12px 0; } footer ul { margin: 0; padding: 0; text-align: center; } footer ul li { display: inline-block; padding: 0 6px; } .prenext { overflow: auto; } .challenge-desc { color: #777; font-style: italic; } #git-tips, .didnt-pass { border: 1px solid #BADFFF; padding: 18px; margin: 18px 0 36px; } .didnt-pass { border-color: #999; } #git-tips h2 { color: #08f; } #git-tips h2, .didnt-pass h2 { margin: -32px -8px 0; float: left; background: #fff; padding: 0 8px; } #git-tips h2 + p { margin-top: 0; } #git-tips p:last-child, .didnt-pass p:last-child { margin-bottom: 0; } #git-tips ul { list-style: none; margin: 0; padding: 0; } #git-tips code, .didnt-pass code { border-color: #0087ff; } #git-tips li { margin-top: 0px; } .challenge, .verify { background-color: #0087ff; color: #fff; padding: 18px 18px 5px; } .verify code { border-color: #fff; display: inline-block; } .verify { margin-top: 30px; margin-bottom: 30px; } #git-tips h4, .challenge h2, .verify h3 { margin-top: 0; } .didnt-pass h4 { margin: 10px 0 0; } .didnt-pass h4:before { content: ' '; font-weight: normal; } .didnt-pass p + h4 { padding-top: 30px; } .verify h3 { display: inline-block; padding-right: 12px; } blockquote { border-left: 2px solid #acacac; padding-left: 30px; margin: 30px 0; color: #acacac; } .weehero { background-color: #0087ff; padding: 30px; text-align: center; color: #fff; font-size: 50px; font-weight: 900; } img { margin: 30px 0 18px; } n, v, adj { position: relative; } .superscript { font-size: 0.6em; position: absolute; top: -20%; line-height: 0.6em; font-weight: normal; white-space: nowrap; opacity: 0.8; } .u-inlineBlock { display: inline-block; } /* new stuff */ #directory-path:empty { display: none; } #<API key>, #directory-path { font-family: Liberation Mono, Monaco, Courier New, monospace; padding: 6px 12px 6px 10px; vertical-align: middle; margin-bottom: 0; font-size: 13px; font-weight: 400; text-align: center; white-space: nowrap; border-right: 1px solid #fff; border-top: 1px solid #fff; border-bottom: 1px solid #fff; margin-left: -3px; } #<API key> { display: none; color: #ff0; } #<API key>.show { display: inline; } #<API key>.show + #directory-path { display: none; } .verify-fail:before { content: ' '; } .verify-pass:before { content: ' '; } #verify-list { list-style: none; padding-left: 0; } #challenge-completed { color: #2BDA9E; font-size: 24px; font-family: "NothingYouCouldDo"; } #challenge-completed h2 { padding: 0; margin: 0; } .<API key> { font-family: "NothingYouCouldDo"; /*background-color: #BADFFF;*/ color: #2BDA9E; padding: 2px 4px; text-transform: uppercase; font-size: 12px; } button { display: inline-block; background-color: #CBCBCB; color: #818181; padding: 6px 12px; margin-bottom: 0; font-size: 12px; font-weight: 400; text-align: center; white-space: nowrap; vertical-align: middle; cursor: pointer; -webkit-user-select: none; border: 1px solid transparent; font-family: 'Source Sans Pro', 'Helvetica Neue', 'Arial', sans-serif; text-transform: uppercase; } button:focus { outline: 0; } button:hover { background-color: #e7e7e7; } button.white { background-color: #fff; color: #0087ff; } button.white:hover { background-color: #eeeeee; } button.white:disabled { background-color: #F5F5F5; color: #C8C8C8; } button.light-blue { background-color: #D2EAFF; color: #86B6E0; } button.light-blue:hover { background-color: #e2effa; } #<API key> { margin-bottom: 11px; } #<API key>:disabled, #get-started:disabled { display: none; } .teal { background: #2BDA9E; color: #fff; } .teal:hover { background: #6EE7BD; color: #fff; } .grey-border { border: 1px solid #818181 }
FROM microsoft/aspnetcore:2.0 ARG source WORKDIR /app EXPOSE 80 COPY ${source:-obj/Docker/publish} . ENTRYPOINT ["dotnet", "WebApi.dll"]
""" recursely """ __version__ = "0.1" __description__ = "Recursive importer for Python submodules" __author__ = "Karol Kuczmarski" __license__ = "Simplified BSD" import sys from recursely._compat import IS_PY3 from recursely.importer import RecursiveImporter from recursely.utils import SentinelList __all__ = ['install'] def install(retroactive=True): """Install the recursive import hook in ``sys.meta_path``, enabling the use of ``__recursive__`` directive. :param retroactive: Whether the hook should be retroactively applied to module's that have been imported before it was installed. """ if RecursiveImporter.is_installed(): return importer = RecursiveImporter() # because the hook is a catch-all one, we ensure that it's always # at the very end of ``sys.meta_path``, so that it's tried only if # no other (more specific) hook has been chosen by Python if IS_PY3: for i in reversed(range(len(sys.meta_path))): ih_module = getattr(sys.meta_path[i], '__module__', '') is_builtin = ih_module == '_frozen_importlib' if not is_builtin: break sys.meta_path = SentinelList( sys.meta_path[:i], sentinels=[importer] + sys.meta_path[i:]) else: sys.meta_path = SentinelList(sys.meta_path, sentinel=importer) # look through already imported packages and recursively import # their submodules, if they contain the ``__recursive__`` directive if retroactive: for module in list(sys.modules.values()): importer.recurse(module)
// This file was procedurally generated from the following sources: // - src/dstr-binding/<API key>.case // - src/dstr-binding/error/for-of-let.template assert.throws(ReferenceError, function() { for (let { x = <API key> } of [{}]) { return; } });
import {Component, OnInit} from '@angular/core'; import {MarketCard} from '../market-card'; import {MarketCardType} from '../market-card-type'; import {MarketService} from '../market.service'; import {Expansion} from '../expansion'; import { GameModeService } from '../game-mode.service'; import { GameMode } from '../game-mode'; @Component({ selector: '<API key>', templateUrl: './market-selection.component.html', styleUrls: ['./market-selection.component.css'] }) export class <API key> implements OnInit { constructor(private marketService: MarketService, private gameModeService: GameModeService) { } cards: MarketCard[]; expeditionMode: boolean; ngOnInit() { this.marketService.marketCards$.subscribe((cards: MarketCard[]) => { this.cards = cards; }); this.cards = this.marketService.marketCards; this.gameModeService.selectedGameMode$.subscribe((newGameMode: GameMode) => { this.<API key>(newGameMode); }); this.<API key>(this.gameModeService.selectedGameMode); } getCardCssClass(type: MarketCardType): string { switch (type) { case MarketCardType.Gem: return 'gem-card'; case MarketCardType.Relic: return 'relic-card'; case MarketCardType.Spell: return 'spell-card'; } } getCardTypeLabel(type: MarketCardType): string { switch (type) { case MarketCardType.Gem: return 'Gem'; case MarketCardType.Relic: return 'Relic'; case MarketCardType.Spell: return 'Spell'; } } private <API key>(gameMode: GameMode): void { this.expeditionMode = (gameMode !== GameMode.SingleGame); } }
package com.lessvoid.coregl; import com.lessvoid.coregl.spi.CoreGL; /** * Simple helper methods to render vertex arrays. * * @author void */ public class CoreRender { private final CoreGL gl; CoreRender(final CoreGL gl) { this.gl = gl; } public static CoreRender createCoreRender(final CoreGL gl) { return new CoreRender(gl); } // Lines /** * Render lines. * * @param count * number of vertices */ public void renderLines(final int count) { gl.glDrawArrays(gl.GL_LINE_STRIP(), 0, count); gl.checkGLError("glDrawArrays"); } /** * Render adjacent lines. * * @param count * number of vertices */ public void renderLinesAdjacent(final int count) { gl.glDrawArrays(gl.<API key>(), 0, count); gl.checkGLError("glDrawArrays"); } // Triangle Strip /** * Render the currently active VAO using triangle strips with the given number * of vertices. * * @param count * number of vertices to render as triangle strips */ public void renderTriangleStrip(final int count) { gl.glDrawArrays(gl.GL_TRIANGLE_STRIP(), 0, count); gl.checkGLError("glDrawArrays"); } /** * Render the currently active VAO using triangle strips, sending the given * number of indizes. * * @param count * number of indizes to render as triangle strips */ public void <API key>(final int count) { gl.glDrawElements(gl.GL_TRIANGLE_STRIP(), count, gl.GL_UNSIGNED_INT(), 0); gl.checkGLError("glDrawElements(GL_TRIANGLE_STRIP)"); } /** * Render the currently active VAO using triangle strips with the given number * of vertices AND do that primCount times. * * @param count * number of vertices to render as triangle strips per primitve * @param primCount * number of primitives to render */ public void <API key>(final int count, final int primCount) { gl.<API key>(gl.GL_TRIANGLE_STRIP(), 0, count, primCount); gl.checkGLError("<API key>(GL_TRIANGLE_STRIP)"); } // Triangle Fan /** * Render the currently active VAO using triangle fan with the given number of * vertices. * * @param count * number of vertices to render as triangle fan */ public void renderTriangleFan(final int count) { gl.glDrawArrays(gl.GL_TRIANGLE_FAN(), 0, count); gl.checkGLError("glDrawArrays"); } /** * Render the currently active VAO using triangle fans, sending the given * number of indizes. * * @param count * number of indizes to render as triangle fans. */ public void <API key>(final int count) { gl.glDrawElements(gl.GL_TRIANGLE_FAN(), count, gl.GL_UNSIGNED_INT(), 0); gl.checkGLError("glDrawElements(GL_TRIANGLE_FAN)"); } // Individual Triangles /** * Render the currently active VAO using triangles with the given number of * vertices. * * @param vertexCount * number of vertices to render as triangle strips */ public void renderTriangles(final int vertexCount) { gl.glDrawArrays(gl.GL_TRIANGLES(), 0, vertexCount); gl.checkGLError("glDrawArrays"); } /** * Render the currently active VAO using triangles with the given number of * vertices starting at the given offset. * * @param offset * offset to start sending vertices * @param vertexCount * number of vertices to render as triangle strips */ public void <API key>(final int offset, final int vertexCount) { gl.glDrawArrays(gl.GL_TRIANGLES(), offset, vertexCount); gl.checkGLError("glDrawArrays"); } /** * Render the currently active VAO using triangles with the given number of * vertices. * * @param count * number of vertices to render as triangles */ public void <API key>(final int count) { gl.glDrawElements(gl.GL_TRIANGLES(), count, gl.GL_UNSIGNED_INT(), 0); gl.checkGLError("glDrawElements"); } /** * Render the currently active VAO using triangles with the given number of * vertices AND do that primCount times. * * @param count * number of vertices to render as triangles per primitve * @param primCount * number of primitives to render */ public void <API key>(final int count, final int primCount) { gl.<API key>(gl.GL_TRIANGLES(), 0, count, primCount); gl.checkGLError("<API key>(GL_TRIANGLES)"); } // Points /** * Render the currently active VAO using points with the given number of * vertices. * * @param count * number of vertices to render as points */ public void renderPoints(final int count) { gl.glDrawArrays(gl.GL_POINTS(), 0, count); gl.checkGLError("glDrawArrays(GL_POINTS)"); } /** * Render the currently active VAO using points with the given number of * vertices AND do that primCount times. * * @param count * number of vertices to render as points per primitive * @param primCount * number of primitives to render */ public void <API key>(final int count, final int primCount) { gl.<API key>(gl.GL_POINTS(), 0, count, primCount); gl.checkGLError("<API key>(GL_POINTS)"); } // Utils /** * Set the clear color. * * @param r * red * @param g * green * @param b * blue * @param a * alpha */ public void clearColor(final float r, final float g, final float b, final float a) { gl.glClearColor(r, g, b, a); } /** * Clear the color buffer. */ public void clearColorBuffer() { gl.glClear(gl.GL_COLOR_BUFFER_BIT()); } }
#include "curl_setup.h" #include <curl/curl.h> #include "urldata.h" #include "getinfo.h" #include "vtls/vtls.h" #include "connect.h" /* Curl_getconnectinfo() */ #include "progress.h" /* The last #include files should be: */ #include "curl_memory.h" #include "memdebug.h" /* * Initialize statistical and informational data. * * This function is called in curl_easy_reset, curl_easy_duphandle and at the * beginning of a perform session. It must reset the session-info variables, * in particular all variables in struct PureInfo. */ CURLcode Curl_initinfo(struct Curl_easy *data) { struct Progress *pro = &data->progress; struct PureInfo *info = &data->info; pro->t_nslookup = 0; pro->t_connect = 0; pro->t_appconnect = 0; pro->t_pretransfer = 0; pro->t_starttransfer = 0; pro->timespent = 0; pro->t_redirect = 0; pro-><API key> = false; info->httpcode = 0; info->httpproxycode = 0; info->httpversion = 0; info->filetime = -1; info->timecond = FALSE; info->header_size = 0; info->request_size = 0; info->proxyauthavail = 0; info->httpauthavail = 0; info->numconnects = 0; free(info->contenttype); info->contenttype = NULL; free(info->wouldredirect); info->wouldredirect = NULL; info->conn_primary_ip[0] = '\0'; info->conn_local_ip[0] = '\0'; info->conn_primary_port = 0; info->conn_local_port = 0; info->conn_scheme = 0; info->conn_protocol = 0; #ifdef USE_SSL <API key>(data); #endif return CURLE_OK; } static CURLcode getinfo_char(struct Curl_easy *data, CURLINFO info, const char **param_charp) { switch(info) { case <API key>: *param_charp = data->change.url?data->change.url:(char *)""; break; case <API key>: *param_charp = data->info.contenttype; break; case CURLINFO_PRIVATE: *param_charp = (char *) data->set.private_data; break; case <API key>: /* Return the entrypath string from the most recent connection. This pointer was copied from the connectdata structure by FTP. The actual string may be free()ed by subsequent libcurl calls so it must be copied to a safer area before the next libcurl call. Callers must never free it themselves. */ *param_charp = data->state.<API key>; break; case <API key>: /* Return the URL this request would have been redirected to if that option had been enabled! */ *param_charp = data->info.wouldredirect; break; case CURLINFO_PRIMARY_IP: /* Return the ip address of the most recent (primary) connection */ *param_charp = data->info.conn_primary_ip; break; case CURLINFO_LOCAL_IP: /* Return the source/local ip address of the most recent (primary) connection */ *param_charp = data->info.conn_local_ip; break; case <API key>: *param_charp = data->set.str[<API key>]; break; case CURLINFO_SCHEME: *param_charp = data->info.conn_scheme; break; default: return <API key>; } return CURLE_OK; } static CURLcode getinfo_long(struct Curl_easy *data, CURLINFO info, long *param_longp) { curl_socket_t sockfd; union { unsigned long *to_ulong; long *to_long; } lptr; #ifdef DEBUGBUILD char *timestr = getenv("CURL_TIME"); if(timestr) { unsigned long val = strtol(timestr, NULL, 10); switch(info) { case CURLINFO_LOCAL_PORT: *param_longp = (long)val; return CURLE_OK; default: break; } } /* use another variable for this to allow different values */ timestr = getenv("CURL_DEBUG_SIZE"); if(timestr) { unsigned long val = strtol(timestr, NULL, 10); switch(info) { case <API key>: case <API key>: *param_longp = (long)val; return CURLE_OK; default: break; } } #endif switch(info) { case <API key>: *param_longp = data->info.httpcode; break; case <API key>: *param_longp = data->info.httpproxycode; break; case CURLINFO_FILETIME: if(data->info.filetime > LONG_MAX) *param_longp = LONG_MAX; else if(data->info.filetime < LONG_MIN) *param_longp = LONG_MIN; else *param_longp = (long)data->info.filetime; break; case <API key>: *param_longp = (long)data->info.header_size; break; case <API key>: *param_longp = (long)data->info.request_size; break; case <API key>: *param_longp = data->set.ssl.certverifyresult; break; case <API key>: *param_longp = data->set.proxy_ssl.certverifyresult; break; case <API key>: *param_longp = data->set.followlocation; break; case <API key>: lptr.to_long = param_longp; *lptr.to_ulong = data->info.httpauthavail; break; case <API key>: lptr.to_long = param_longp; *lptr.to_ulong = data->info.proxyauthavail; break; case CURLINFO_OS_ERRNO: *param_longp = data->state.os_errno; break; case <API key>: *param_longp = data->info.numconnects; break; case CURLINFO_LASTSOCKET: sockfd = Curl_getconnectinfo(data, NULL); /* note: this is not a good conversion for systems with 64 bit sockets and 32 bit longs */ if(sockfd != CURL_SOCKET_BAD) *param_longp = (long)sockfd; else /* this interface is documented to return -1 in case of badness, which may not be the same as the CURL_SOCKET_BAD value */ *param_longp = -1; break; case <API key>: /* Return the (remote) port of the most recent (primary) connection */ *param_longp = data->info.conn_primary_port; break; case CURLINFO_LOCAL_PORT: /* Return the local port of the most recent (primary) connection */ *param_longp = data->info.conn_local_port; break; case <API key>: if(data->info.httpcode == 304) *param_longp = 1L; else /* return if the condition prevented the document to get transferred */ *param_longp = data->info.timecond ? 1L : 0L; break; case <API key>: *param_longp = data->state.<API key>; break; case <API key>: *param_longp = data->state.<API key>; break; case <API key>: *param_longp = data->state.rtsp_CSeq_recv; break; case <API key>: switch(data->info.httpversion) { case 10: *param_longp = <API key>; break; case 11: *param_longp = <API key>; break; case 20: *param_longp = <API key>; break; case 30: *param_longp = CURL_HTTP_VERSION_3; break; default: *param_longp = <API key>; break; } break; case CURLINFO_PROTOCOL: *param_longp = data->info.conn_protocol; break; default: return <API key>; } return CURLE_OK; } #define DOUBLE_SECS(x) (double)(x)/1000000 static CURLcode getinfo_offt(struct Curl_easy *data, CURLINFO info, curl_off_t *param_offt) { #ifdef DEBUGBUILD char *timestr = getenv("CURL_TIME"); if(timestr) { unsigned long val = strtol(timestr, NULL, 10); switch(info) { case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: *param_offt = (curl_off_t)val; return CURLE_OK; default: break; } } #endif switch(info) { case CURLINFO_FILETIME_T: *param_offt = (curl_off_t)data->info.filetime; break; case <API key>: *param_offt = data->progress.uploaded; break; case <API key>: *param_offt = data->progress.downloaded; break; case <API key>: *param_offt = data->progress.dlspeed; break; case <API key>: *param_offt = data->progress.ulspeed; break; case <API key>: *param_offt = (data->progress.flags & PGRS_DL_SIZE_KNOWN)? data->progress.size_dl:-1; break; case <API key>: *param_offt = (data->progress.flags & PGRS_UL_SIZE_KNOWN)? data->progress.size_ul:-1; break; case <API key>: *param_offt = data->progress.timespent; break; case <API key>: *param_offt = data->progress.t_nslookup; break; case <API key>: *param_offt = data->progress.t_connect; break; case <API key>: *param_offt = data->progress.t_appconnect; break; case <API key>: *param_offt = data->progress.t_pretransfer; break; case <API key>: *param_offt = data->progress.t_starttransfer; break; case <API key>: *param_offt = data->progress.t_redirect; break; case <API key>: *param_offt = data->info.retry_after; break; default: return <API key>; } return CURLE_OK; } static CURLcode getinfo_double(struct Curl_easy *data, CURLINFO info, double *param_doublep) { #ifdef DEBUGBUILD char *timestr = getenv("CURL_TIME"); if(timestr) { unsigned long val = strtol(timestr, NULL, 10); switch(info) { case CURLINFO_TOTAL_TIME: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: case <API key>: *param_doublep = (double)val; return CURLE_OK; default: break; } } #endif switch(info) { case CURLINFO_TOTAL_TIME: *param_doublep = DOUBLE_SECS(data->progress.timespent); break; case <API key>: *param_doublep = DOUBLE_SECS(data->progress.t_nslookup); break; case <API key>: *param_doublep = DOUBLE_SECS(data->progress.t_connect); break; case <API key>: *param_doublep = DOUBLE_SECS(data->progress.t_appconnect); break; case <API key>: *param_doublep = DOUBLE_SECS(data->progress.t_pretransfer); break; case <API key>: *param_doublep = DOUBLE_SECS(data->progress.t_starttransfer); break; case <API key>: *param_doublep = (double)data->progress.uploaded; break; case <API key>: *param_doublep = (double)data->progress.downloaded; break; case <API key>: *param_doublep = (double)data->progress.dlspeed; break; case <API key>: *param_doublep = (double)data->progress.ulspeed; break; case <API key>: *param_doublep = (data->progress.flags & PGRS_DL_SIZE_KNOWN)? (double)data->progress.size_dl:-1; break; case <API key>: *param_doublep = (data->progress.flags & PGRS_UL_SIZE_KNOWN)? (double)data->progress.size_ul:-1; break; case <API key>: *param_doublep = DOUBLE_SECS(data->progress.t_redirect); break; default: return <API key>; } return CURLE_OK; } static CURLcode getinfo_slist(struct Curl_easy *data, CURLINFO info, struct curl_slist **param_slistp) { union { struct curl_certinfo *to_certinfo; struct curl_slist *to_slist; } ptr; switch(info) { case <API key>: *param_slistp = <API key>(data); break; case CURLINFO_COOKIELIST: *param_slistp = Curl_cookie_list(data); break; case CURLINFO_CERTINFO: /* Return the a pointer to the certinfo struct. Not really an slist pointer but we can pretend it is here */ ptr.to_certinfo = &data->info.certs; *param_slistp = ptr.to_slist; break; case <API key>: case <API key>: { struct curl_tlssessioninfo **tsip = (struct curl_tlssessioninfo **) param_slistp; struct curl_tlssessioninfo *tsi = &data->tsi; #ifdef USE_SSL struct connectdata *conn = data->conn; #endif *tsip = tsi; tsi->backend = Curl_ssl_backend(); tsi->internals = NULL; #ifdef USE_SSL if(conn && tsi->backend != CURLSSLBACKEND_NONE) { unsigned int i; for(i = 0; i < (sizeof(conn->ssl) / sizeof(conn->ssl[0])); ++i) { if(conn->ssl[i].use) { tsi->internals = Curl_ssl->get_internals(&conn->ssl[i], info); break; } } } #endif } break; default: return <API key>; } return CURLE_OK; } static CURLcode getinfo_socket(struct Curl_easy *data, CURLINFO info, curl_socket_t *param_socketp) { switch(info) { case <API key>: *param_socketp = Curl_getconnectinfo(data, NULL); break; default: return <API key>; } return CURLE_OK; } CURLcode Curl_getinfo(struct Curl_easy *data, CURLINFO info, ...) { va_list arg; long *param_longp = NULL; double *param_doublep = NULL; curl_off_t *param_offt = NULL; const char **param_charp = NULL; struct curl_slist **param_slistp = NULL; curl_socket_t *param_socketp = NULL; int type; CURLcode result = <API key>; if(!data) return result; va_start(arg, info); type = CURLINFO_TYPEMASK & (int)info; switch(type) { case CURLINFO_STRING: param_charp = va_arg(arg, const char **); if(param_charp) result = getinfo_char(data, info, param_charp); break; case CURLINFO_LONG: param_longp = va_arg(arg, long *); if(param_longp) result = getinfo_long(data, info, param_longp); break; case CURLINFO_DOUBLE: param_doublep = va_arg(arg, double *); if(param_doublep) result = getinfo_double(data, info, param_doublep); break; case CURLINFO_OFF_T: param_offt = va_arg(arg, curl_off_t *); if(param_offt) result = getinfo_offt(data, info, param_offt); break; case CURLINFO_SLIST: param_slistp = va_arg(arg, struct curl_slist **); if(param_slistp) result = getinfo_slist(data, info, param_slistp); break; case CURLINFO_SOCKET: param_socketp = va_arg(arg, curl_socket_t *); if(param_socketp) result = getinfo_socket(data, info, param_socketp); break; default: break; } va_end(arg); return result; }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http: <html xmlns="http: <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Simulation &#8212; OSIM 0.1 documentation</title> <link rel="stylesheet" href="_static/alabaster.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script type="text/javascript"> var <API key> = { URL_ROOT: './', VERSION: '0.1', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; </script> <script type="text/javascript" src="_static/jquery.js"></script> <script type="text/javascript" src="_static/underscore.js"></script> <script type="text/javascript" src="_static/doctools.js"></script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=<API key>"></script> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> <link rel="next" title="Optimization" href="Optimization.html" /> <link rel="prev" title="Components" href="Components.html" /> <link rel="stylesheet" href="_static/custom.css" type="text/css" /> <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" /> </head> <body role="document"> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <div class="section" id="simulation"> <h1>Simulation<a class="headerlink" href=" <div class="section" id="module-Simulation.NetToComp"> <span id="<API key>"></span><h2>Simulation.NetToComp<a class="headerlink" href=" <p>Use the triangle class to represent triangles.</p> <dl class="class"> <dt id="Simulation.NetToComp.NetToComp"> <em class="property">class </em><code class="descclassname">Simulation.NetToComp.</code><code class="descname">NetToComp</code><span class="sig-paren">(</span><em>filename</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/Simulation/NetToComp.html <dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">object</span></code></p> <p>Beispielkommentar</p> <dl class="method"> <dt id="Simulation.NetToComp.NetToComp.<API key>"> <code class="descname"><API key></code><span class="sig-paren">(</span><em>netListFile</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/Simulation/NetToComp.html <dd><p>Create a triangle with sides of lengths <cite>a</cite>, <cite>b</cite>, and <cite>c</cite>.</p> <p>Raises <cite>ValueError</cite> if the three length values provided cannot actually form a triangle.</p> </dd></dl> <dl class="method"> <dt id="Simulation.NetToComp.NetToComp.getComponents"> <code class="descname">getComponents</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/Simulation/NetToComp.html <dd><p>Create a triangle with sides of lengths <cite>a</cite>, <cite>b</cite>, and <cite>c</cite>.</p> <p>Raises <cite>ValueError</cite> if the three length values provided cannot actually form a triangle.</p> </dd></dl> <dl class="method"> <dt id="Simulation.NetToComp.NetToComp.parseCommentsToArgs"> <code class="descname">parseCommentsToArgs</code><span class="sig-paren">(</span><em>args</em>, <em>commentList</em>, <em>name</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/Simulation/NetToComp.html <dd></dd></dl> <dl class="method"> <dt id="Simulation.NetToComp.NetToComp.stringArrToDict"> <code class="descname">stringArrToDict</code><span class="sig-paren">(</span><em>strArr</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/Simulation/NetToComp.html <dd><p>Create a triangle with sides of lengths <cite>a</cite>, <cite>b</cite>, and <cite>c</cite>.</p> <p>Raises <cite>ValueError</cite> if the three length values provided cannot actually form a triangle.</p> </dd></dl> </dd></dl> </div> </div> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="<API key>"> <h3><a href="index.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">Simulation</a><ul> <li><a class="reference internal" href="#module-Simulation.NetToComp">Simulation.NetToComp</a></li> </ul> </li> </ul> <div class="relations"> <h3>Related Topics</h3> <ul> <li><a href="index.html">Documentation overview</a><ul> <li>Previous: <a href="Components.html" title="previous chapter">Components</a></li> <li>Next: <a href="Optimization.html" title="next chapter">Optimization</a></li> </ul></li> </ul> </div> <div role="note" aria-label="source link"> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="_sources/Simulation.rst.txt" rel="nofollow">Show Source</a></li> </ul> </div> <div id="searchbox" style="display: none" role="search"> <h3>Quick search</h3> <form class="search" action="search.html" method="get"> <div><input type="text" name="q" /></div> <div><input type="submit" value="Go" /></div> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="footer"> &copy;2017, Tim Maiwald. | Powered by <a href="http://sphinx-doc.org/">Sphinx 1.5.4</a> &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.9</a> | <a href="_sources/Simulation.rst.txt" rel="nofollow">Page source</a> </div> </body> </html>
# coding: utf-8 import sys from setuptools import setup, find_packages NAME = "pollster" VERSION = "2.0.2" # To install the library, run the following # python setup.py install # prerequisite: setuptools REQUIRES = ["urllib3 >= 1.15", "six >= 1.10", "certifi", "python-dateutil", "pandas >= 0.19.1"] setup( name=NAME, version=VERSION, description="Pollster API", author_email="Adam Hooper <adam.hooper@huffingtonpost.com>", url="https://github.com/huffpostdata/python-pollster", keywords=["Pollster API"], install_requires=REQUIRES, packages=find_packages(), <API key>=True, long_description="""Download election-related polling data from Pollster.""" )
import requests import logging import redis from requests.packages.urllib3.exceptions import ConnectionError from core.serialisers import json from dss import localsettings # TODO(fergal.moran@gmail.com): refactor these out to # classes to avoid duplicating constants below HEADERS = { 'content-type': 'application/json' } logger = logging.getLogger('spa') def post_notification(session_id, image, message): try: payload = { 'sessionid': session_id, 'image': image, 'message': message } data = json.dumps(payload) r = requests.post( localsettings.REALTIME_HOST + 'notification', data=data, headers=HEADERS ) if r.status_code == 200: return "" else: return r.text except ConnectionError: #should probably implement some sort of retry in here pass
unless ENV["HOMEBREW_BREW_FILE"] raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!" end require "constants" require "tmpdir" require "pathname" HOMEBREW_BREW_FILE = Pathname.new(ENV["HOMEBREW_BREW_FILE"]) TEST_TMPDIR = ENV.fetch("<API key>") do |k| dir = Dir.mktmpdir("homebrew-tests-", ENV["HOMEBREW_TEMP"] || "/tmp") at_exit { FileUtils.remove_entry(dir) } ENV[k] = dir end # Paths pointing into the Homebrew code base that persist across test runs <API key> = Pathname.new(File.expand_path("../../../..", __FILE__)) HOMEBREW_SHIMS_PATH = <API key>.parent+"Homebrew/shims" HOMEBREW_LOAD_PATH = [File.expand_path("..", __FILE__), <API key>].join(":") # Paths redirected to a temporary directory and wiped at the end of the test run HOMEBREW_PREFIX = Pathname.new(TEST_TMPDIR).join("prefix") HOMEBREW_REPOSITORY = HOMEBREW_PREFIX HOMEBREW_LIBRARY = HOMEBREW_REPOSITORY+"Library" HOMEBREW_CACHE = HOMEBREW_PREFIX.parent+"cache" <API key> = HOMEBREW_PREFIX.parent+"formula_cache" <API key> = HOMEBREW_PREFIX.parent+"linked" <API key> = HOMEBREW_PREFIX.parent+"pinned" HOMEBREW_LOCK_DIR = HOMEBREW_PREFIX.parent+"locks" HOMEBREW_CELLAR = HOMEBREW_PREFIX.parent+"cellar" HOMEBREW_LOGS = HOMEBREW_PREFIX.parent+"logs" HOMEBREW_TEMP = HOMEBREW_PREFIX.parent+"temp" TEST_FIXTURE_DIR = <API key>.join("test", "support", "fixtures") TESTBALL_SHA1 = "<SHA1-like>".freeze TESTBALL_SHA256 = "<SHA256-like>".freeze <API key> = "<SHA256-like>".freeze PATCH_A_SHA256 = "<SHA256-like>".freeze PATCH_B_SHA256 = "<SHA256-like>".freeze <API key> = "<SHA256-like>".freeze TEST_SHA1 = "<SHA1-like>".freeze TEST_SHA256 = "<SHA256-like>".freeze
include(<API key>) include(<API key>) include(<API key>) include(<API key>) include(hunter_fatal_error) include(<API key>) include(<API key>) include(hunter_status_debug) include(hunter_status_print) include(<API key>) # Continue initialization of key variables (also see 'hunter_initialize') # * calculate toolchain-id # * calculate config-id macro(hunter_finalize) # Check preconditions <API key>() list(APPEND <API key> "https://github.com/ingenue/hunter-cache") list(REMOVE_DUPLICATES <API key>) hunter_status_debug("List of cache servers:") foreach(_server ${<API key>}) hunter_status_debug(" * ${_server}") endforeach() get_property(_enabled_languages GLOBAL PROPERTY ENABLED_LANGUAGES) list(FIND _enabled_languages "C" _c_enabled_result) if(_c_enabled_result EQUAL -1) set(_c_enabled FALSE) else() set(_c_enabled TRUE) endif() list(FIND _enabled_languages "CXX" _cxx_enabled_result) if(_cxx_enabled_result EQUAL -1) set(_cxx_enabled FALSE) else() set(_cxx_enabled TRUE) endif() if(_c_enabled AND NOT <API key>) hunter_fatal_error( "ABI not detected for C compiler" WIKI "error.abi.detection.failure" ) endif() if(_cxx_enabled AND NOT <API key>) hunter_fatal_error( "ABI not detected for CXX compiler" WIKI "error.abi.detection.failure" ) endif() string(COMPARE NOTEQUAL "$ENV{HUNTER_BINARY_DIR}" "" _env_not_empty) if(_env_not_empty) <API key>(HUNTER_BINARY_DIR "$ENV{HUNTER_BINARY_DIR}" ABSOLUTE) hunter_status_debug("HUNTER_BINARY_DIR: ${HUNTER_BINARY_DIR}") endif() # * Read HUNTER_GATE_* variables # * Check cache HUNTER_* variables is up-to-date # * Update cache if needed <API key>() string(SUBSTRING "${HUNTER_SHA1}" 0 7 HUNTER_ID) string(SUBSTRING "${HUNTER_CONFIG_SHA1}" 0 7 HUNTER_CONFIG_ID) string(SUBSTRING "${<API key>}" 0 7 HUNTER_TOOLCHAIN_ID) set(HUNTER_ID_PATH "${HUNTER_CACHED_ROOT}/_Base/${HUNTER_ID}") set(<API key> "${HUNTER_ID_PATH}/${HUNTER_CONFIG_ID}") set( <API key> "${<API key>}/${HUNTER_TOOLCHAIN_ID}" ) set(<API key> "${<API key>}/Install") list(APPEND CMAKE_PREFIX_PATH "${<API key>}") if(ANDROID) list(APPEND CMAKE_PREFIX_PATH "${<API key>}/sdk/native/jni") endif() list(APPEND <API key> "${<API key>}") hunter_status_print("HUNTER_ROOT: ${HUNTER_CACHED_ROOT}") hunter_status_debug("<API key>: ${<API key>}") hunter_status_debug( "<API key>: ${<API key>}" ) set(_id_info "[ Hunter-ID: ${HUNTER_ID} |") set(_id_info "${_id_info} Config-ID: ${HUNTER_CONFIG_ID} |") set(_id_info "${_id_info} Toolchain-ID: ${HUNTER_TOOLCHAIN_ID} ]") hunter_status_print("${_id_info}") set(HUNTER_CACHE_FILE "${<API key>}/cache.cmake") <API key>("${HUNTER_CACHE_FILE}") if(MSVC) include(hunter_setup_msvc) hunter_setup_msvc() endif() Disable package registry http://www.cmake.org/cmake/help/v3.1/manual/cmake-packages.7.html#<API key> set(<API key> ON) set(<API key> ON) set(<API key> ON) -- end Disable environment variables http: set(ENV{CMAKE_PREFIX_PATH} "") set(ENV{<API key>} "") set(ENV{<API key>} "") -- end 1. Clear all '<NAME>_ROOT' variables (cache, environment, ...) 2. Set '<NAME>_ROOT' or 'HUNTER_<name>_VERSION' variables set(<API key> YES) include("${<API key>}/config.cmake") set(<API key> NO) <API key>("${<API key>}") <API key>("${CMAKE_BINARY_DIR}") file( WRITE "${CMAKE_BINARY_DIR}/_3rdParty/Hunter/install-root-dir" "${<API key>}" ) <API key>() if(ANDROID AND CMAKE_VERSION VERSION_LESS "3.7.1") hunter_user_error( "CMake version 3.7.1+ required for Android platforms, see" " https://docs.hunter.sh/en/latest/quick-start/cmake.html" ) endif() # Android GDBSERVER moved to # Fix backslashed provided by user: # Note: we can't use '<API key>(... ABSOLUTE)' because sometimes # original path expected. E.g. NMake build: string(REPLACE "\\" "\\\\" CMAKE_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}") endmacro()
# modification, are permitted provided that the following conditions are met: # and/or other materials provided with the distribution. # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __version__ = '0.6.4-dev'
/* * $Log$ * Revision 0.01 2009/09/20 ulrichprinz * First checkin of using DBGU as limited standard USART. * */ //#define NUT_DEPRECATED #include <cfg/os.h> #include <cfg/clock.h> #include <cfg/arch.h> #include <cfg/uart.h> #include <string.h> #include <sys/atom.h> #include <sys/event.h> #include <sys/timer.h> #include <dev/irqreg.h> #include <dev/debug.h> #include <arch/cm3.h> #include <arch/arm/at91_dbgu.h> #include <dev/usartat91.h> /* * Local function prototypes. * * Commented functions are not supported by DBGU * */ static uint32_t At91UsartGetSpeed(void); static int At91UsartSetSpeed(uint32_t rate); static uint8_t <API key>(void); static int <API key>( uint8_t bits); static uint8_t At91UsartGetParity(void); static int At91UsartSetParity(uint8_t mode); static uint8_t <API key>(void); static int <API key>(uint8_t bits); static uint32_t At91UsartGetStatus(void); static int At91UsartSetStatus(uint32_t flags); static uint8_t <API key>(void); static int <API key>(uint8_t mode); static void At91UsartTxStart(void); static void At91UsartRxStart(void); static int At91UsartInit(void); static int At91UsartDeinit(void); static uint32_t <API key>(void); static int <API key>(uint32_t flags); #define sig_DBGU sig_UART #define DBGU_BASE AT91C_BASE_DBGU #define US_ID AT91C_ID_DBGU #define PMC_PCER AT91C_PMC_PCER #define PMC_PCDR AT91C_PMC_PCDR extern IRQ_HANDLER sig_DBGU; /*! * \addtogroup xgNutArchArmAt91Us */ /*! * \brief DBGU device control block structure. */ static USARTDCB dcb_dbgu = { 0, /* dcb_modeflags */ 0, /* dcb_statusflags */ 0, /* dcb_rtimeout */ 0, /* dcb_wtimeout */ {0, 0, 0, 0, 0, 0, 0, 0}, /* dcb_tx_rbf */ {0, 0, 0, 0, 0, 0, 0, 0}, /* dcb_rx_rbf */ 0, /* dbc_last_eol */ At91UsartInit, /* dcb_init */ At91UsartDeinit, /* dcb_deinit */ At91UsartTxStart, /* dcb_tx_start */ At91UsartRxStart, /* dcb_rx_start */ <API key>, /* <API key> */ <API key>, /* <API key> */ At91UsartSetSpeed, /* dcb_set_speed */ At91UsartGetSpeed, /* dcb_get_speed */ <API key>, /* dcb_set_data_bits */ <API key>, /* dcb_get_data_bits */ At91UsartSetParity, /* dcb_set_parity */ At91UsartGetParity, /* dcb_get_parity */ <API key>, /* dcb_set_stop_bits */ <API key>, /* dcb_get_stop_bits */ At91UsartSetStatus, /* dcb_set_status */ At91UsartGetStatus, /* dcb_get_status */ <API key>, /* dcb_set_clock_mode */ <API key>, /* dcb_get_clock_mode */ }; /*! * \name AT91 DBGU Device */ /*! * \brief USART0 device information structure. * * An application must pass a pointer to this structure to * NutRegisterDevice() before using the serial communication * driver of the AT91's on-chip USART0. * * The device is named \b uart0. * * \showinitializer */ NUTDEVICE devDebug = { 0, /* Pointer to next device, dev_next. */ {'d', 'b', 'g', 'u', 0, 0, 0, 0, 0}, /* Unique device name, dev_name. */ IFTYP_CHAR, /* Type of device, dev_type. */ AT91C_BASE_DBGU, /* Base address, dev_base (not used). */ 0, /* First interrupt number, dev_irq (not used). */ 0, /* Interface control block, dev_icb (not used). */ &dcb_dbgu, /* Driver control block, dev_dcb. */ UsartInit, /* Driver initialization routine, dev_init. */ UsartIOCtl, /* Driver specific control function, dev_ioctl. */ UsartRead, /* Read from device, dev_read. */ UsartWrite, /* Write to device, dev_write. */ UsartOpen, /* Open a device or file, dev_open. */ UsartClose, /* Close a device or file, dev_close. */ UsartSize /* Request file size, dev_size. */ }; /* Modem control includes hardware handshake. */ /* * Hardware driven control signals are not available * with the DBUG unit of most chips. */ #undef UART_MODEM_CONTROL #undef <API key> #define UART_RXTX_PINS (AT91C_PA11_DRXD|AT91C_PA12_DTXD) #undef UART_HDX_PIN #undef UART_RTS_PIN #undef UART_CTS_PIN #undef UART_MODEM_PINS #define <API key>() outr(AT91C_PIOA_PDR, UART_RXTX_PINS) #define UART_INIT_BAUDRATE 115200 #define USARTn_BASE AT91C_BASE_DBGU #define US_ID AT91C_ID_DBGU #define SIG_UART sig_UART #define dcb_usart dcb_dbgu #include "usartat91.c"
# Use of this source code is governed by a BSD-style from django.conf import settings from django.conf.urls import include, patterns, url from django.views.decorators import csrf from django.views.generic import base from django.contrib import admin admin.autodiscover() from devincachu.destaques import views as dviews from devincachu.inscricao import views as iviews from devincachu.palestras import views as pviews p = patterns urlpatterns = p("", url(r"^admin/", include(admin.site.urls)), url(r"^palestrantes/$", pviews.PalestrantesView.as_view(), name="palestrantes"), url(r"^programacao/$", pviews.ProgramacaoView.as_view(), name="programacao"), url(r"^programacao/(?P<palestrantes>.*)/(?P<slug>[\w-]+)/$", pviews.PalestraView.as_view(), name="palestra"), url(r"^inscricao/$", iviews.Inscricao.as_view(), name="inscricao"), url(r"^notificacao/$", csrf.csrf_exempt(iviews.Notificacao.as_view()), name="notificacao"), url(r"^certificado/validar/$", iviews.<API key>.as_view(), name="<API key>"), url(r"^certificado/$", iviews.BuscarCertificado.as_view(), name="busca_certificado"), url(r"^certificado/(?P<slug>[0-9a-f]+)/$", iviews.Certificado.as_view(), name="certificado"), url(r"^sobre/$", base.TemplateView.as_view( template_name="sobre.html", ), name="sobre-o-evento"), url(r"^quando-e-onde/$", base.TemplateView.as_view( template_name="quando-e-onde.html", ), name="quando-e-onde"), url(r"^$", dviews.IndexView.as_view(), name="index"), ) if settings.DEBUG: urlpatterns += patterns("", url(r"^media/(?P<path>.*)$", "django.views.static.serve", {"document_root": settings.MEDIA_ROOT}), )
{-# LANGUAGE TupleSections #-} module Arbitrary.TestModule where import Data.Integrated.TestModule import Test.QuickCheck import Data.ModulePath import Control.Applicative import Arbitrary.Properties import Test.Util import Filesystem.Path.CurrentOS import Prelude hiding (FilePath) import qualified Arbitrary.ModulePath as MP import qualified Data.Set as S testModulePath :: Gen Char -> S.Set ModulePath -> Gen ModulePath testModulePath subpath avoided = suchThat (fromModPath <$> MP.toModulePath subpath) (not . flip S.member avoided) where fromModPath :: ModulePath -> ModulePath fromModPath (ModulePath pth) = ModulePath $ take (length pth - 1) pth ++ [testFormat $ last pth] toTestModule :: ModulePath -> Gen TestModule toTestModule mp = do props <- arbitrary :: Gen Properties return $ TestModule mp (list props) -- Generate a random test file, care must be taken to avoid generating -- the same path twice toGenerated :: Gen Char -> S.Set ModulePath -> Gen (FilePath, TestModule) toGenerated subpath avoided = do mp <- testModulePath subpath avoided (relPath mp,) <$> toTestModule mp
# -*- coding: utf-8 -*- class Pkg @pkgDir @jailDir def self.init() @pkgDir = System.getConf("pkgDir") @jailDir = System.getConf("jailDir") end def self.main(data) if (data["control"] == "search") then search(data["name"]).each_line do |pname| pname = pname.chomp SendMsg.machine("pkg","search",pname) end elsif(data["control"] == "list") then pkg = list("all") pkg.each do |pname| SendMsg.machine("pkg","list",pname[0]) end elsif(data["control"] == "install") then cmdLog,cause = install(data["name"]) if(cmdLog == false) SendMsg.status(MACHINE,"failed",cause) return else SendMsg.status(MACHINE,"success","") end end end def self.add(jname,pname) puts "pkg-static -j #{jname} add /pkg/#{pname}.txz" s,e = Open3.capture3("pkg-static -j #{jname} add /pkg/#{pname}.txz") end def self.search(pname) #host s,e = Open3.capture3("pkg-static search #{pname}") return s end def self.download(pname) flag = false pkgVal = 0 now = 1 IO.popen("echo y|pkg-static fetch -d #{pname}") do |pipe| pipe.each do | line | # puts line if(line.include?("New packages to be FETCHED:")) then #(NEw packagesThe process) flag = true end if(line.include?("The process will require")) then pkgVal -= 2 flag = false end if(flag == true) then pkgVal += 1 end if(line.include?("Fetching")) then if(line.include?("Proceed with fetching packages? [y/N]: ")) then line.gsub!("Proceed with fetching packages? [y/N]: ","") end SendMsg.status(MACHINE,"log","#{line}(#{now}/#{pkgVal})") now += 1 end end end cmdLog,e = Open3.capture3("ls #{@jailDir}/sharedfs/pkg")
#!/usr/bin/env python # modification, are permitted provided that the following conditions # are met: # with the distribution. # * Neither the name of the Willow Garage nor the names of its # contributors may be used to endorse or promote products derived # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. import roslib; roslib.load_manifest('face_detection') import rospy import sys import cv from cv_bridge import CvBridge from sensor_msgs.msg import Image from geometry_msgs.msg import Point from geometry_msgs.msg import PointStamped # Instantiate a new opencv to ROS bridge adaptor cv_bridge = CvBridge() # Define the callback that will be called when a new image is received. def callback(publisher, coord_publisher, cascade, imagemsg): # Convert the ROS imagemsg to an opencv image. image = cv_bridge.imgmsg_to_cv(imagemsg, 'mono8') # Blur the image. cv.Smooth(image, image, cv.CV_GAUSSIAN) # Allocate some storage for the haar detect operation. storage = cv.CreateMemStorage(0) # Call the face detector function. faces = cv.HaarDetectObjects(image, cascade, storage, 1.2, 2, cv.<API key>, (100,100)) # If faces are detected, compute the centroid of all the faces # combined. face_centroid_x = 0.0 face_centroid_y = 0.0 if len(faces) > 0: # For each face, draw a rectangle around it in the image, # and also add the position of the face to the centroid # of all faces combined. for (i, n) in faces: x = int(i[0]) y = int(i[1]) width = int(i[2]) height = int(i[3]) cv.Rectangle(image, (x, y), (x + width, y + height), cv.CV_RGB(0,255,0), 3, 8, 0) face_centroid_x += float(x) + (float(width) / 2.0) face_centroid_y += float(y) + (float(height) / 2.0) # Finish computing the face_centroid by dividing by the # number of faces found above. face_centroid_x /= float(len(faces)) face_centroid_y /= float(len(faces)) # Lastly, if faces were detected, publish a PointStamped # message that contains the centroid values. pt = Point(x = face_centroid_x, y = face_centroid_y, z = 0.0) pt_stamped = PointStamped(point = pt) coord_publisher.publish(pt_stamped) # Convert the opencv image back to a ROS image using the # cv_bridge. newmsg = cv_bridge.cv_to_imgmsg(image, 'mono8') # Republish the image. Note this image has boxes around # faces if faces were found. publisher.publish(newmsg) def listener(publisher, coord_publisher): rospy.init_node('face_detector', anonymous=True) # Load the haar cascade. Note we get the # filename from the "classifier" parameter # that is configured in the launch script. cascadeFileName = rospy.get_param("~classifier") cascade = cv.Load(cascadeFileName) rospy.Subscriber("/stereo/left/image_rect", Image, lambda image: callback(publisher, coord_publisher, cascade, image)) rospy.spin() # This is called first. if __name__ == '__main__': publisher = rospy.Publisher('face_view', Image) coord_publisher = rospy.Publisher('face_coords', PointStamped) listener(publisher, coord_publisher)
#! /usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function import urllib from OpenGL.GL import * from OpenGL.GLU import * from OpenGL.GLUT import * from jp.ac.kyoto_su.aokilab.dragon.mvc.model import OpenGLModel from jp.ac.kyoto_su.aokilab.dragon.mvc.view import * from jp.ac.kyoto_su.aokilab.dragon.opengl.triangle import OpenGLTriangle from jp.ac.kyoto_su.aokilab.dragon.opengl.polygon import OpenGLPolygon TRACE = True DEBUG = False class DragonModel(OpenGLModel): def __init__(self): if TRACE: print(__name__), self.__init__.__doc__ super(DragonModel, self).__init__() self._eye_point = [-5.5852450791872 , 3.07847342734 , 15.794105252496] self._sight_point = [0.27455347776413 , 0.20096999406815 , -0.11261999607086] self._up_vector = [0.1018574904194 , 0.98480906061847 , -0.14062775604137] self._fovy = self._default_fovy = 12.642721790235 filename = os.path.join(os.getcwd(), 'dragon.txt') if os.path.exists(filename) and os.path.isfile(filename): pass else: url = 'http: urllib.urlretrieve(url, filename) with open(filename, "rU") as a_file: while True: a_string = a_file.readline() if len(a_string) == 0: break a_list = a_string.split() if len(a_list) == 0: continue first_string = a_list[0] if first_string == "number_of_vertexes": number_of_vertexes = int(a_list[1]) if first_string == "number_of_triangles": number_of_triangles = int(a_list[1]) if first_string == "end_header": get_tokens = (lambda file: file.readline().split()) <API key> = [] for n_th in range(number_of_vertexes): a_list = get_tokens(a_file) a_vertex = map(float, a_list[0:3]) <API key>.append(a_vertex) index_to_vertex = (lambda index: <API key>[index-1]) for n_th in range(number_of_triangles): a_list = get_tokens(a_file) indexes = map(int, a_list[0:3]) vertexes = map(index_to_vertex, indexes) a_tringle = OpenGLTriangle(*vertexes) self._display_object.append(a_tringle) return def <API key>(self): if TRACE: print(__name__), self.<API key>.__doc__ return "Dragon" class WaspModel(OpenGLModel): def __init__(self): if TRACE: print(__name__), self.__init__.__doc__ super(WaspModel, self).__init__() self._eye_point = [-5.5852450791872 , 3.07847342734 , 15.794105252496] self._sight_point = [0.19825005531311 , 1.8530999422073 , -0.63795006275177] self._up_vector = [0.070077999093727 , 0.99630606032682 , -0.049631725731267] self._fovy = self._default_fovy = 41.480099231656 filename = os.path.join(os.getcwd(), 'wasp.txt') if os.path.exists(filename) and os.path.isfile(filename): pass else: url = 'http: urllib.urlretrieve(url, filename) with open(filename, "rU") as a_file: while True: a_string = a_file.readline() if len(a_string) == 0: break a_list = a_string.split() if len(a_list) == 0: continue first_string = a_list[0] if first_string == "number_of_vertexes": number_of_vertexes = int(a_list[1]) if first_string == "number_of_polygons": number_of_polygons = int(a_list[1]) if first_string == "end_header": get_tokens = (lambda file: file.readline().split()) <API key> = [] for n_th in range(number_of_vertexes): a_list = get_tokens(a_file) a_vertex = map(float, a_list[0:3]) <API key>.append(a_vertex) index_to_vertex = (lambda index: <API key>[index-1]) for n_th in range(number_of_polygons): a_list = get_tokens(a_file) number_of_indexes = int(a_list[0]) index = number_of_indexes + 1 indexes = map(int, a_list[1:index]) vertexes = map(index_to_vertex, indexes) rgb_color = map(float, a_list[index:index+3]) a_polygon = OpenGLPolygon(vertexes, rgb_color) self._display_object.append(a_polygon) return def default_view_class(self): if TRACE: print(__name__), self.default_view_class.__doc__ return WaspView def <API key>(self): if TRACE: print(__name__), self.<API key>.__doc__ return "Wasp" class BunnyModel(OpenGLModel): def __init__(self): if TRACE: print(__name__), self.__init__.__doc__ super(BunnyModel, self).__init__() filename = os.path.join(os.getcwd(), 'bunny.ply') if os.path.exists(filename) and os.path.isfile(filename): pass else: url = 'http: urllib.urlretrieve(url, filename) with open(filename, "rU") as a_file: while True: a_string = a_file.readline() if len(a_string) == 0: break a_list = a_string.split() if len(a_list) == 0: continue first_string = a_list[0] if first_string == "element": second_string = a_list[1] if second_string == "vertex": number_of_vertexes = int(a_list[2]) if second_string == "face": number_of_faces = int(a_list[2]) if first_string == "end_header": get_tokens = (lambda file: file.readline().split()) <API key> = [] for n_th in range(number_of_vertexes): a_list = get_tokens(a_file) a_vertex = map(float, a_list[0:3]) <API key>.append(a_vertex) index_to_vertex = (lambda index: <API key>[index]) for n_th in range(number_of_faces): a_list = get_tokens(a_file) indexes = map(int, a_list[1:4]) vertexes = map(index_to_vertex, indexes) a_tringle = OpenGLTriangle(*vertexes) self._display_object.append(a_tringle) if first_string == "comment": second_string = a_list[1] if second_string == "eye_point_xyz": self._eye_point = map(float, a_list[2:5]) if second_string == "sight_point_xyz": self._sight_point = map(float, a_list[2:5]) if second_string == "up_vector_xyz": self._up_vector = map(float, a_list[2:5]) if second_string == "zoom_height" and a_list[3] == "fovy": self._fovy = self._default_fovy = float(a_list[4]) return def default_view_class(self): if TRACE: print(__name__), self.default_view_class.__doc__ return BunnyView def <API key>(self): if TRACE: print(__name__), self.<API key>.__doc__ return "Stanford Bunny" # end of file
from lino.core.roles import UserRole class SimpleContactsUser(UserRole): pass class ContactsUser(SimpleContactsUser): pass class ContactsStaff(ContactsUser): pass
#ifndef COAP_BLOCK_H_ #define COAP_BLOCK_H_ #include "encode.h" #include "option.h" #include "pdu.h" /** * @defgroup block Block Transfer * API functions for handling PDUs using CoAP BLOCK options * @{ */ #ifndef COAP_MAX_BLOCK_SZX /** * The largest value for the SZX component in a Block option. */ #define COAP_MAX_BLOCK_SZX 6 #endif /* COAP_MAX_BLOCK_SZX */ /** * Structure of Block options. */ typedef struct { unsigned int num; /**< block number */ unsigned int m:1; /**< 1 if more blocks follow, 0 otherwise */ unsigned int szx:3; /**< block size */ } coap_block_t; #define <API key> 0x01 /* Use libcoap to do block requests */ #define <API key> 0x02 /* Deliver the data as a single body */ /** * Returns the value of the least significant byte of a Block option @p opt. * For zero-length options (i.e. num == m == szx == 0), COAP_OPT_BLOCK_LAST * returns @c NULL. */ #define COAP_OPT_BLOCK_LAST(opt) \ (coap_opt_length(opt) ? (coap_opt_value(opt) + (coap_opt_length(opt)-1)) : 0) /** Returns the value of the More-bit of a Block option @p opt. */ #define COAP_OPT_BLOCK_MORE(opt) \ (coap_opt_length(opt) ? (*COAP_OPT_BLOCK_LAST(opt) & 0x08) : 0) /** Returns the value of the SZX-field of a Block option @p opt. */ #define COAP_OPT_BLOCK_SZX(opt) \ (coap_opt_length(opt) ? (*COAP_OPT_BLOCK_LAST(opt) & 0x07) : 0) /** * Returns the value of field @c num in the given block option @p block_opt. */ unsigned int coap_opt_block_num(const coap_opt_t *block_opt); /** * Checks if more than @p num blocks are required to deliver @p data_len * bytes of data for a block size of 1 << (@p szx + 4). */ COAP_STATIC_INLINE int coap_more_blocks(size_t data_len, unsigned int num, uint16_t szx) { return ((num+1) << (szx + 4)) < data_len; } #if 0 /** Sets the More-bit in @p block_opt */ COAP_STATIC_INLINE void <API key>(coap_opt_t *block_opt, int m) { if (m) *(coap_opt_value(block_opt) + (coap_opt_length(block_opt) - 1)) |= 0x08; else *(coap_opt_value(block_opt) + (coap_opt_length(block_opt) - 1)) &= ~0x08; } #endif /** * Initializes @p block from @p pdu. @p number must be either COAP_OPTION_BLOCK1 * or COAP_OPTION_BLOCK2. When option @p number was found in @p pdu, @p block is * initialized with values from this option and the function returns the value * @c 1. Otherwise, @c 0 is returned. * * @param pdu The pdu to search for option @p number. * @param number The option number to search for (must be COAP_OPTION_BLOCK1 or * COAP_OPTION_BLOCK2). * @param block The block structure to initilize. * * @return @c 1 on success, @c 0 otherwise. */ int coap_get_block(const coap_pdu_t *pdu, coap_option_num_t number, coap_block_t *block); /** * Writes a block option of type @p number to message @p pdu. If the requested * block size is too large to fit in @p pdu, it is reduced accordingly. An * exception is made for the final block when less space is required. The actual * length of the resource is specified in @p data_length. * * This function may change *block to reflect the values written to @p pdu. As * the function takes into consideration the remaining space @p pdu, no more * options should be added after <API key>() has returned. * * @param block The block structure to use. On return, this object is * updated according to the values that have been written to * @p pdu. * @param number COAP_OPTION_BLOCK1 or COAP_OPTION_BLOCK2. * @param pdu The message where the block option should be written. * @param data_length The length of the actual data that will be added the @p * pdu by calling coap_add_block(). * * @return @c 1 on success, or a negative value on error. */ int <API key>(coap_block_t *block, coap_option_num_t number, coap_pdu_t *pdu, size_t data_length); /** * Adds the @p block_num block of size 1 << (@p block_szx + 4) from source @p * data to @p pdu. * * @param pdu The message to add the block. * @param len The length of @p data. * @param data The source data to fill the block with. * @param block_num The actual block number. * @param block_szx Encoded size of block @p block_number. * * @return @c 1 on success, @c 0 otherwise. */ int coap_add_block(coap_pdu_t *pdu, size_t len, const uint8_t *data, unsigned int block_num, unsigned char block_szx); /** * Re-assemble payloads into a body * * @param body_data The pointer to the data for the body holding the * representation so far or NULL if the first time. * @param length The length of @p data. * @param data The payload data to update the body with. * @param offset The offset of the @p data into the body. * @param total The estimated total size of the body. * * @return The current representation of the body or @c NULL if error. * If NULL, @p body_data will have been de-allocated. */ coap_binary_t * <API key>(coap_binary_t *body_data, size_t length, const uint8_t *data, size_t offset, size_t total); /** * Adds the appropriate part of @p data to the @p response pdu. If blocks are * required, then the appropriate block will be added to the PDU and sent. * Adds a ETAG option that is the hash of the entire data if the data is to be * split into blocks * Used by a request handler. * * Note: The application will get called for every packet of a large body to * process. Consider using <API key>() instead. * * @param request The requesting pdu. * @param response The response pdu. * @param media_type The format of the data. * @param maxage The maxmimum life of the data. If @c -1, then there * is no maxage. * @param length The total length of the data. * @param data The entire data block to transmit. * */ void <API key>(const coap_pdu_t *request, coap_pdu_t *response, uint16_t media_type, int maxage, size_t length, const uint8_t* data); /** * Callback handler for de-allocating the data based on @p app_ptr provided to * <API key>*() functions following transmission of the supplied * data. * * @param session The session that this data is associated with * @param app_ptr The application provided pointer provided to the * <API key>* functions. */ typedef void (*<API key>)(coap_session_t *session, void *app_ptr); /** * Associates given data with the @p pdu that is passed as second parameter. * * If all the data can be transmitted in a single PDU, this is functionally * the same as coap_add_data() except @p release_func (if not NULL) will get * invoked after data transmission. * * Used for a client request. * * If the data spans multiple PDUs, then the data will get transmitted using * BLOCK1 option with the addition of the SIZE1 option. * The underlying library will handle the transmission of the individual blocks. * Once the body of data has been transmitted (or a failure occurred), then * @p release_func (if not NULL) will get called so the application can * de-allocate the @p data based on @p app_data. It is the responsibility of * the application not to change the contents of @p data until the data * transfer has completed. * * There is no need for the application to include the BLOCK1 option in the * @p pdu. * * <API key>() (or the alternative <API key>*() * functions) must be called only once per PDU and must be the last PDU update * before the PDU is transmitted. The (potentially) initial data will get * transmitted when coap_send() is invoked. * * Note: <API key> must be set by <API key>() * for libcoap to work correctly when using this function. * * @param session The session to associate the data with. * @param pdu The PDU to associate the data with. * @param length The length of data to transmit. * @param data The data to transmit. * @param release_func The function to call to de-allocate @p data or @c NULL * if the function is not required. * @param app_ptr A Pointer that the application can provide for when * release_func() is called. * * @return @c 1 if addition is successful, else @c 0. */ int <API key>(coap_session_t *session, coap_pdu_t *pdu, size_t length, const uint8_t *data, <API key> release_func, void *app_ptr); /** * Associates given data with the @p response pdu that is passed as fourth * parameter. * * If all the data can be transmitted in a single PDU, this is functionally * the same as coap_add_data() except @p release_func (if not NULL) will get * invoked after data transmission. The MEDIA_TYPE, MAXAGE and ETAG options may * be added in as appropriate. * * Used by a server request handler to create the response. * * If the data spans multiple PDUs, then the data will get transmitted using * BLOCK2 (response) option with the addition of the SIZE2 and ETAG * options. The underlying library will handle the transmission of the * individual blocks. Once the body of data has been transmitted (or a * failure occurred), then @p release_func (if not NULL) will get called so the * application can de-allocate the @p data based on @p app_data. It is the * responsibility of the application not to change the contents of @p data * until the data transfer has completed. * * There is no need for the application to include the BLOCK2 option in the * @p pdu. * * <API key>() (or the alternative coap_add_data_large*() * functions) must be called only once per PDU and must be the last PDU update * before returning from the request handler function. * * Note: <API key> must be set by <API key>() * for libcoap to work correctly when using this function. * * @param resource The resource the data is associated with. * @param session The coap session. * @param request The requesting pdu. * @param response The response pdu. * @param query The query taken from the (original) requesting pdu. * @param media_type The format of the data. * @param maxage The maxmimum life of the data. If @c -1, then there * is no maxage. * @param etag ETag to use if not 0. * @param length The total length of the data. * @param data The entire data block to transmit. * @param release_func The function to call to de-allocate @p data or NULL if * the function is not required. * @param app_ptr A Pointer that the application can provide for when * release_func() is called. * * @return @c 1 if addition is successful, else @c 0. */ int <API key>(coap_resource_t *resource, coap_session_t *session, const coap_pdu_t *request, coap_pdu_t *response, const coap_string_t *query, uint16_t media_type, int maxage, uint64_t etag, size_t length, const uint8_t *data, <API key> release_func, void *app_ptr); /** * Set the context level CoAP block handling bits for handling RFC7959. * These bits flow down to a session when a session is created and if the peer * does not support something, an appropriate bit may get disabled in the * session block_mode. * The session block_mode then flows down into coap_crcv_t or coap_srcv_t where * again an appropriate bit may get disabled. * * Note: This function must be called before the session is set up. * * Note: <API key> must be set if libcoap is to do all the * block tracking and requesting, otherwise the application will have to do * all of this work (the default if <API key>() is not * called). * * @param context The coap_context_t object. * @param block_mode Zero or more COAP_BLOCK_ or'd options */ void <API key>(coap_context_t *context, uint8_t block_mode); /** * Cancel an observe that is being tracked by the client large receive logic. * (<API key>() has to be called) * This will trigger the sending of an observe cancel pdu to the server. * * @param session The session that is being used for the observe. * @param token The original token used to initiate the observation. * @param message_type The COAP_MESSAGE_ type (NON or CON) to send the observe * cancel pdu as. * * @return @c 1 if observe cancel transmission initiation is successful, * else @c 0. */ int coap_cancel_observe(coap_session_t *session, coap_binary_t *token, coap_pdu_type_t message_type); #endif /* COAP_BLOCK_H_ */
from django.db.models import Transform from django.db.models import DateTimeField, TimeField from django.utils.functional import cached_property class TimeValue(Transform): lookup_name = 'time' function = 'time' def as_sql(self, compiler, connection): lhs, params = compiler.compile(self.lhs) return 'TIME({})'.format(lhs), params @cached_property def output_field(self): return TimeField() DateTimeField.register_lookup(TimeValue)
#include <errno.h> #include <unistd.h> #include <sys/types.h> // define function pointer typedef off64_t (*llamaos_lseek64_t) (int, off64_t, int); // function pointer variable static llamaos_lseek64_t llamaos_lseek64 = 0; // function called by llamaOS to register pointer void <API key> (llamaos_lseek64_t func) { llamaos_lseek64 = func; } /* Seek to OFFSET on FD, starting from WHENCE. */ off64_t __libc_lseek64 (int fd, off64_t offset, int whence) { if (0 != llamaos_lseek64) { if (fd < 0) { __set_errno (EBADF); return -1; } switch (whence) { case SEEK_SET: case SEEK_CUR: case SEEK_END: break; default: __set_errno (EINVAL); return -1; } return llamaos_lseek64 (fd, offset, whence); } __set_errno (ENOSYS); return -1; } weak_alias (__libc_lseek64, __lseek64) weak_alias (__libc_lseek64, lseek64)
<?php header('Content-Type: text/html; charset=utf-8'); require_once 'Akna.php'; $user = ''; $pass = ''; $akna = new Akna( $user, $pass ); $contacts = $akna->emailMarketing->contacts; $messages = $akna->emailMarketing->messages; $campaigns = $akna->emailMarketing->campaigns; try { // $result_1 = $contacts->get('daniel@apiki.com', 'Apiki 1'); // var_dump($result_1); // $result_2 = $contacts->getLists(); // var_dump($result_2); // $result_3 = $messages->create( array( // 'nome' => 'Teste', // var_dump($result_3); // $result_4 = $messages->test( array( // 'titulo' => 'Teste', // 'email_remetente' => 'daniel.antunes.rocha@gmail.com', // 'assunto' => 'Teste de envio 15.07', // 'email' => 'daniel@apiki.com' // var_dump($result_4); // $result_5 = $campaigns->addAction( array( // 'mensagem' => 'Teste', // 'data_encerramento' => '2013-07-30', // 'email_remetente' => 'firb.cesp@firb.com', // 'email_retorno' => 'firb.cesp@firb.com', // 'assunto' => 'Assunto 1', // 'lista' => array( 'Apiki 1', 'Apiki 2' ), // 'agendar' => array( 'datahora' => date( 'Y-m-d H:i:s' ) ) // var_dump($result_5); } catch( Akna_Exception $e ){ echo $e->getmessage(); }
// Use of this source code is governed by a BSD-style package sequtil import ( "errors" "github.com/dmiller/go-seq/iseq" "github.com/dmiller/go-seq/murmur3" //"fmt" "math" "reflect" ) // Hash returns a hash code for an object. // Uses iseq.Hashable.Hash if the interface is implemented. // Otherwise, special cases Go numbers and strings. // Returns a default value if not covered by these cases. // Returning a default value is really not good for hashing performance. // But it is one way not to have an error code and to avoid a panic. // Use IsHashable to determine if Hash is supported. // Or call HashE which has an error return. func Hash(v interface{}) uint32 { h, err := HashE(v) if err != nil { return 0 } return h } // HashE returns a hash code for an object. // Uses iseq.Hashable.Hash if the interface is implemented. // It special cases Go numbers and strings. // Returns an error if the object is not covered by these cases. func HashE(v interface{}) (uint32, error) { if h, ok := v.(iseq.Hashable); ok { return h.Hash(), nil } switch v := v.(type) { case bool, int, int8, int32, int64: return murmur3.HashUInt64(uint64(reflect.ValueOf(v).Int())), nil case uint, uint8, uint32, uint64: return murmur3.HashUInt64(uint64(reflect.ValueOf(v).Uint())), nil case float32, float64: return murmur3.HashUInt64(math.Float64bits(reflect.ValueOf(v).Float())), nil case nil: return murmur3.HashUInt64(0), nil case string: return murmur3.HashString(v), nil case complex64, complex128: return HashComplex128(v.(complex128)), nil } return 0, errors.New("don't know how to hash") } // IsHashable returns true if Hash/HashE can compute a hash for this object. func IsHashable(v interface{}) bool { if _, ok := v.(iseq.Hashable); ok { return true } switch v.(type) { case bool, int, int8, int32, int64, uint, uint8, uint32, uint64, float32, float64, nil, string, complex64, complex128: return true } return false } // HashSeq computes a hash for an iseq.Seq func HashSeq(s iseq.Seq) uint32 { return HashOrdered(s) } // HashMap computes a hash for an iseq.PMap func HashMap(m iseq.PMap) uint32 { return HashUnordered(m.Seq()) } // HashOrdered computes a hash for an iseq.Seq, where order is important func HashOrdered(s iseq.Seq) uint32 { n := int32(0) hash := uint32(1) for ; s != nil; s = s.Next() { hash = 31*hash + Hash(s.First) n++ } return murmur3.FinalizeCollHash(hash, n) } // HashUnordered computes a hash for an iseq.Seq, independent of order of elements func HashUnordered(s iseq.Seq) uint32 { n := int32(0) hash := uint32(0) for ; s != nil; s = s.Next() { hash += Hash(s.First) n++ } return murmur3.FinalizeCollHash(hash, n) } // HashComplex128 computes a hash for a complex128 func HashComplex128(c complex128) uint32 { hash := murmur3.MixHash( murmur3.HashUInt64(math.Float64bits(real(c))), murmur3.HashUInt64(math.Float64bits(imag(c)))) return murmur3.Finalize(hash, 2) }
#pragma once #include "AffineTransform.h" #include "CanvasPathMethods.h" #include "<API key>.h" #include "CanvasStyle.h" #include "Color.h" #include "FloatSize.h" #include "FontCascade.h" #include "FontSelectorClient.h" #include "GraphicsContext.h" #include "GraphicsTypes.h" #include "ImageBuffer.h" #include "Path.h" #include "PlatformLayer.h" #include "TextFlags.h" #include <wtf/Vector.h> #include <wtf/text/WTFString.h> namespace WebCore { class CanvasGradient; class CanvasPattern; class DOMPath; class FloatRect; class GraphicsContext; class HTMLCanvasElement; class HTMLImageElement; class HTMLVideoElement; class ImageData; class TextMetrics; typedef int ExceptionCode; class <API key> final : public <API key>, public CanvasPathMethods { public: <API key>(HTMLCanvasElement*, bool <API key>, bool <API key>); virtual ~<API key>(); const CanvasStyle& strokeStyle() const { return state().strokeStyle; } void setStrokeStyle(CanvasStyle); const CanvasStyle& fillStyle() const { return state().fillStyle; } void setFillStyle(CanvasStyle); float lineWidth() const; void setLineWidth(float); String lineCap() const; void setLineCap(const String&); String lineJoin() const; void setLineJoin(const String&); float miterLimit() const; void setMiterLimit(float); const Vector<float>& getLineDash() const; void setLineDash(const Vector<float>&); void setWebkitLineDash(const Vector<float>&); float lineDashOffset() const; void setLineDashOffset(float); float <API key>() const; void <API key>(float); float shadowOffsetX() const; void setShadowOffsetX(float); float shadowOffsetY() const; void setShadowOffsetY(float); float shadowBlur() const; void setShadowBlur(float); String shadowColor() const; void setShadowColor(const String&); float globalAlpha() const; void setGlobalAlpha(float); String <API key>() const; void <API key>(const String&); void save() { ++<API key>; } void restore(); void scale(float sx, float sy); void rotate(float angleInRadians); void translate(float tx, float ty); void transform(float m11, float m12, float m21, float m22, float dx, float dy); void setTransform(float m11, float m12, float m21, float m22, float dx, float dy); void setStrokeColor(const String& color, Optional<float> alpha = Nullopt); void setStrokeColor(float grayLevel, float alpha = 1.0); void setStrokeColor(float r, float g, float b, float a); void setStrokeColor(float c, float m, float y, float k, float a); void setFillColor(const String& color, Optional<float> alpha = Nullopt); void setFillColor(float grayLevel, float alpha = 1.0f); void setFillColor(float r, float g, float b, float a); void setFillColor(float c, float m, float y, float k, float a); void beginPath(); enum class WindingRule { Nonzero, Evenodd }; void fill(WindingRule = WindingRule::Nonzero); void stroke(); void clip(WindingRule = WindingRule::Nonzero); void fill(DOMPath&, WindingRule = WindingRule::Nonzero); void stroke(DOMPath&); void clip(DOMPath&, WindingRule = WindingRule::Nonzero); bool isPointInPath(float x, float y, WindingRule = WindingRule::Nonzero); bool isPointInStroke(float x, float y); bool isPointInPath(DOMPath&, float x, float y, WindingRule = WindingRule::Nonzero); bool isPointInStroke(DOMPath&, float x, float y); void clearRect(float x, float y, float width, float height); void fillRect(float x, float y, float width, float height); void strokeRect(float x, float y, float width, float height); void setShadow(float width, float height, float blur, const String& color = String(), Optional<float> alpha = Nullopt); void setShadow(float width, float height, float blur, float grayLevel, float alpha = 1.0); void setShadow(float width, float height, float blur, float r, float g, float b, float a); void setShadow(float width, float height, float blur, float c, float m, float y, float k, float a); void clearShadow(); void drawImage(HTMLImageElement&, float x, float y, ExceptionCode&); void drawImage(HTMLImageElement&, float x, float y, float width, float height, ExceptionCode&); void drawImage(HTMLImageElement&, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh, ExceptionCode&); void drawImage(HTMLImageElement&, const FloatRect& srcRect, const FloatRect& dstRect, ExceptionCode&); void drawImage(HTMLCanvasElement&, float x, float y, ExceptionCode&); void drawImage(HTMLCanvasElement&, float x, float y, float width, float height, ExceptionCode&); void drawImage(HTMLCanvasElement&, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh, ExceptionCode&); void drawImage(HTMLCanvasElement&, const FloatRect& srcRect, const FloatRect& dstRect, ExceptionCode&); void drawImage(HTMLImageElement&, const FloatRect& srcRect, const FloatRect& dstRect, const CompositeOperator&, const BlendMode&, ExceptionCode&); #if ENABLE(VIDEO) void drawImage(HTMLVideoElement&, float x, float y, ExceptionCode&); void drawImage(HTMLVideoElement&, float x, float y, float width, float height, ExceptionCode&); void drawImage(HTMLVideoElement&, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh, ExceptionCode&); void drawImage(HTMLVideoElement&, const FloatRect& srcRect, const FloatRect& dstRect, ExceptionCode&); #endif void drawImageFromRect(HTMLImageElement&, float sx = 0, float sy = 0, float sw = 0, float sh = 0, float dx = 0, float dy = 0, float dw = 0, float dh = 0, const String& compositeOperation = emptyString()); void setAlpha(float); void <API key>(const String&); RefPtr<CanvasGradient> <API key>(float x0, float y0, float x1, float y1, ExceptionCode&); RefPtr<CanvasGradient> <API key>(float x0, float y0, float r0, float x1, float y1, float r1, ExceptionCode&); RefPtr<CanvasPattern> createPattern(HTMLImageElement&, const String& repetitionType, ExceptionCode&); RefPtr<CanvasPattern> createPattern(HTMLCanvasElement&, const String& repetitionType, ExceptionCode&); #if ENABLE(VIDEO) RefPtr<CanvasPattern> createPattern(HTMLVideoElement&, const String& repetitionType, ExceptionCode&); #endif RefPtr<ImageData> createImageData(RefPtr<ImageData>&&, ExceptionCode&) const; RefPtr<ImageData> createImageData(float width, float height, ExceptionCode&) const; RefPtr<ImageData> getImageData(float sx, float sy, float sw, float sh, ExceptionCode&) const; RefPtr<ImageData> <API key>(float sx, float sy, float sw, float sh, ExceptionCode&) const; void putImageData(ImageData&, float dx, float dy, ExceptionCode&); void putImageData(ImageData&, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight, ExceptionCode&); void <API key>(ImageData&, float dx, float dy, ExceptionCode&); void <API key>(ImageData&, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight, ExceptionCode&); void drawFocusIfNeeded(Element*); void drawFocusIfNeeded(DOMPath&, Element*); float <API key>() const { return 1; } void reset(); String font() const; void setFont(const String&); String textAlign() const; void setTextAlign(const String&); String textBaseline() const; void setTextBaseline(const String&); String direction() const; void setDirection(const String&); void fillText(const String& text, float x, float y, Optional<float> maxWidth = Nullopt); void strokeText(const String& text, float x, float y, Optional<float> maxWidth = Nullopt); Ref<TextMetrics> measureText(const String& text); LineCap getLineCap() const { return state().lineCap; } LineJoin getLineJoin() const { return state().lineJoin; } bool <API key>() const; void <API key>(bool); enum class <API key> { Low, Medium, High }; <API key> <API key>() const; void <API key>(<API key>); bool <API key>() const { return <API key>; }; void <API key>(bool flag) { <API key> = flag; }; bool <API key>() const { return <API key>; } void <API key>(bool); String displayListAsText(DisplayList::AsTextFlags) const; String <API key>(DisplayList::AsTextFlags) const; private: enum class Direction { Inherit, RTL, LTR }; class FontProxy : public FontSelectorClient { public: FontProxy() = default; virtual ~FontProxy(); FontProxy(const FontProxy&); FontProxy& operator=(const FontProxy&); bool realized() const { return m_font.fontSelector(); } void initialize(FontSelector&, const RenderStyle&); FontMetrics fontMetrics() const; const <API key>& fontDescription() const; float width(const TextRun&) const; void drawBidiText(GraphicsContext&, const TextRun&, const FloatPoint&, FontCascade::<API key>) const; private: void update(FontSelector&); void fontsNeedUpdate(FontSelector&) override; FontCascade m_font; }; struct State final { State(); State(const State&); State& operator=(const State&); String unparsedStrokeColor; String unparsedFillColor; CanvasStyle strokeStyle; CanvasStyle fillStyle; float lineWidth; LineCap lineCap; LineJoin lineJoin; float miterLimit; FloatSize shadowOffset; float shadowBlur; RGBA32 shadowColor; float globalAlpha; CompositeOperator globalComposite; BlendMode globalBlend; AffineTransform transform; bool <API key>; Vector<float> lineDash; float lineDashOffset; bool <API key>; <API key> <API key>; // Text state. TextAlign textAlign; TextBaseline textBaseline; Direction direction; String unparsedFont; FontProxy font; }; enum CanvasDidDrawOption { <API key> = 0, <API key> = 1, <API key> = 1 << 1, <API key> = 1 << 2, <API key> = 0xffffffff }; State& modifiableState() { ASSERT(!<API key>); return m_stateStack.last(); } const State& state() const { return m_stateStack.last(); } void applyLineDash() const; void setShadow(const FloatSize& offset, float blur, RGBA32 color); void applyShadow(); bool shouldDrawShadows() const; void didDraw(const FloatRect&, unsigned options = <API key>); void didDrawEntireCanvas(); void <API key>() override; GraphicsContext* drawingContext() const; void unwindStateStack(); void realizeSaves() { if (<API key>) realizeSavesLoop(); } void realizeSavesLoop(); void applyStrokePattern(); void applyFillPattern(); void drawTextInternal(const String& text, float x, float y, bool fill, Optional<float> maxWidth = Nullopt); // The relationship between FontCascade and <API key>::FontProxy must hold certain invariants. // Therefore, all font operations must pass through the State. const FontProxy& fontProxy(); #if ENABLE(DASHBOARD_SUPPORT) void <API key>(); #endif void beginCompositeLayer(); void endCompositeLayer(); void fillInternal(const Path&, WindingRule); void strokeInternal(const Path&); void clipInternal(const Path&, WindingRule); bool <API key>(const Path&, float x, float y, WindingRule); bool <API key>(const Path&, float x, float y); void <API key>(const Path&, Element*); void clearCanvas(); Path <API key>(const Path&) const; Path <API key>(const FloatRect&) const; bool rectContainsCanvas(const FloatRect&) const; template<class T> IntRect <API key>(const T&, IntSize*); std::unique_ptr<ImageBuffer> <API key>(const IntRect&); void compositeBuffer(ImageBuffer&, const IntRect&, CompositeOperator); void inflateStrokeRect(FloatRect&) const; template<class T> void <API key>(T&, const FloatRect&, const FloatRect&, CompositeOperator); void <API key>(CanvasGradient& gradient) const; RefPtr<ImageData> getImageData(ImageBuffer::CoordinateSystem, float sx, float sy, float sw, float sh, ExceptionCode&) const; void putImageData(ImageData&, ImageBuffer::CoordinateSystem, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight, ExceptionCode&); bool is2d() const override { return true; } bool isAccelerated() const override; bool <API key>() const override { return state().<API key>; } TextDirection toTextDirection(Direction, const RenderStyle** computedStyle = nullptr) const; #if ENABLE(<API key>) PlatformLayer* platformLayer() const override; #endif Vector<State, 1> m_stateStack; unsigned <API key> { 0 }; bool <API key>; #if ENABLE(DASHBOARD_SUPPORT) bool <API key>; #endif bool <API key> { false }; bool <API key> { false }; mutable std::unique_ptr<struct <API key>> m_recordingContext; }; } // namespace WebCore <API key>(WebCore::<API key>, is2d())
#include <stdlib.h> #include <string.h> #include <stdio.h> #include "vm_strings.h" #include <assert.h> String *String_alloc(size_t length) { String *p = (String *)calloc(1, sizeof(String) + (length+1) * sizeof(char)); p->length = length; return p; } String *String_new(char *orig) { String *s = String_alloc(strlen(orig)); strcpy(s->str, orig); return s; } String *String_dup(String *orig) { String *s = String_alloc(orig->length); strcpy(s->str, orig->str); return s; } String *String_from_char(char c) { char buf[2] = {c, '\0'}; return String_new(buf); } String *String_from_int(int value) { char buf[50]; sprintf(buf,"%d",value); return String_new(buf); } int String_len(String *s) { if (s == NULL) { fprintf(stderr, "len() cannot be applied to NULL string object\n"); return -1; } return (int)s->length; } String *String_add(String *s, String *t) { if ( s == NULL && t == NULL) { fprintf(stderr, "Addition Operator cannot be applied to two NULL string objects\n"); return NIL_STRING; } if ( s == NULL ) return t; // don't REF/DEREF as we might free our return value if ( t == NULL ) return s; size_t n = strlen(s->str) + strlen(t->str); String *u = String_alloc(n); strcpy(u->str, s->str); strcat(u->str, t->str); return u; } bool String_eq(String *s, String *t) { assert(s); assert(t); return strcmp(s->str, t->str) == 0; } bool String_neq(String *s, String *t) { return !String_eq(s,t); } bool String_gt(String *s, String *t) { assert(s); assert(t); return strcmp(s->str, t->str) > 0; } bool String_ge(String *s, String *t) { assert(s); assert(t); return strcmp(s->str, t->str) >= 0; } bool String_lt(String *s, String *t) { assert(s); assert(t); return strcmp(s->str, t->str) < 0; } bool String_le(String *s, String *t) { assert(s); assert(t); return strcmp(s->str, t->str) <= 0; }
#!/usr/bin/env python __author__ = 'Adam R. Smith, Michael Meisinger, Dave Foster <dfoster@asascience.com>' import threading import traceback import gevent from gevent import greenlet, Timeout from gevent.event import Event, AsyncResult from gevent.queue import Queue from pyon.core import MSG_HEADER_ACTOR from pyon.core.bootstrap import CFG from pyon.core.exception import IonException, ContainerError from pyon.core.exception import Timeout as IonTimeout from pyon.core.thread import PyonThreadManager, PyonThread, ThreadManager, PyonThreadTraceback, PyonHeartbeatError from pyon.datastore.postgresql.pg_util import init_db_stats, get_db_stats, clear_db_stats from pyon.ion.service import BaseService from pyon.util.containers import get_ion_ts, get_ion_ts_millis from pyon.util.log import log <API key> = 60000 # Interval time for process saturation stats collection stats_callback = None class <API key>(BaseException): """ Interrupted exception. Used by external items timing out execution in the IonProcessThread's control thread. Derived from BaseException to specifically avoid try/except Exception blocks, such as in Publisher's publish_event. """ pass class IonProcessError(StandardError): pass class IonProcessThread(PyonThread): """ The control part of an ION process. """ def __init__(self, target=None, listeners=None, name=None, service=None, cleanup_method=None, heartbeat_secs=10, **kwargs): """ Constructs the control part of an ION process. Used by the container's <API key>, as part of spawn_process. @param target A callable to run in the PyonThread. If None (typical), will use the target method defined in this class. @param listeners A list of listening endpoints attached to this thread. @param name The name of this ION process. @param service An instance of the BaseService derived class which contains the business logic for the ION process. @param cleanup_method An optional callable to run when the process is stopping. Runs after all other notify_stop calls have run. Should take one param, this instance. @param heartbeat_secs Number of seconds to wait in between heartbeats. """ self._startup_listeners = listeners or [] self.listeners = [] self._listener_map = {} self.name = name self.service = service self._cleanup_method = cleanup_method self.thread_manager = ThreadManager(<API key>=self._child_failed) # bubbles up to main thread manager self._dead_children = [] # save any dead children for forensics self._ctrl_thread = None self._ctrl_queue = Queue() self._ready_control = Event() self._errors = [] self._ctrl_current = None # set to the AR generated by _routing_call when in the context of a call # processing vs idle time (ms) self._start_time = None self._proc_time = 0 # busy time since start self._proc_time_prior = 0 # busy time at the beginning of the prior interval self._proc_time_prior2 = 0 # busy time at the beginning of 2 interval's ago self._proc_interval_num = 0 # interval num of last record # for heartbeats, used to detect stuck processes self._heartbeat_secs = heartbeat_secs # amount of time to wait between heartbeats self._heartbeat_stack = None # stacktrace of last heartbeat self._heartbeat_time = None # timestamp of heart beat last matching the current op self._heartbeat_op = None # last operation (by AR) self._heartbeat_count = 0 # number of times this operation has been seen consecutively self._log_call_exception = CFG.get_safe("container.process.log_exceptions", False) self._log_call_dbstats = CFG.get_safe("container.process.log_dbstats", False) self.<API key> = CFG.get_safe("container.process.<API key>", 0) PyonThread.__init__(self, target=target, **kwargs) def heartbeat(self): """ Returns a 3-tuple indicating everything is ok. Should only be called after the process has been started. Checks the following: - All attached endpoints are alive + listening (this means ready) - The control flow greenlet is alive + listening or processing @return 3-tuple indicating (listeners ok, ctrl thread ok, heartbeat status). Use all on it for a boolean indication of success. """ listeners_ok = True for l in self.listeners: if not (l in self._listener_map and not self._listener_map[l].proc.dead and l.get_ready_event().is_set()): listeners_ok = False ctrl_thread_ok = self._ctrl_thread.running # are we currently processing something? heartbeat_ok = True if self._ctrl_current is not None: st = traceback.extract_stack(self._ctrl_thread.proc.gr_frame) if self._ctrl_current == self._heartbeat_op: if st == self._heartbeat_stack: self._heartbeat_count += 1 # we've seen this before! increment count # we've been in this for the last X ticks, or it's been X seconds, fail this part of the heartbeat if self._heartbeat_count > CFG.get_safe('container.timeout.<API key>', 30) or \ get_ion_ts_millis() - int(self._heartbeat_time) >= CFG.get_safe('container.timeout.<API key>', 30) * 1000: heartbeat_ok = False else: # it's made some progress self._heartbeat_count = 1 self._heartbeat_stack = st self._heartbeat_time = get_ion_ts() else: self._heartbeat_op = self._ctrl_current self._heartbeat_count = 1 self._heartbeat_time = get_ion_ts() self._heartbeat_stack = st else: self._heartbeat_op = None self._heartbeat_count = 0 #log.debug("%s %s %s", listeners_ok, ctrl_thread_ok, heartbeat_ok) return (listeners_ok, ctrl_thread_ok, heartbeat_ok) @property def time_stats(self): """ Returns a 5-tuple of (total time, idle time, processing time, time since prior interval start, busy since prior interval start), all in ms (int). """ now = get_ion_ts_millis() running_time = now - self._start_time idle_time = running_time - self._proc_time cur_interval = now / <API key> now_since_prior = now - (cur_interval - 1) * <API key> if cur_interval == self._proc_interval_num: <API key> = self._proc_time-self._proc_time_prior2 elif cur_interval-1 == self._proc_interval_num: <API key> = self._proc_time-self._proc_time_prior else: <API key> = 0 return (running_time, idle_time, self._proc_time, now_since_prior, <API key>) def _child_failed(self, child): """ Callback from gevent as set in the TheadManager, when a child greenlet fails. Kills the ION process main greenlet. This propagates the error up to the process supervisor. """ # remove the child from the list of children (so we can shut down cleanly) for x in self.thread_manager.children: if x.proc == child: self.thread_manager.children.remove(x) break self._dead_children.append(child) # kill this process's main greenlet. This should be noticed by the container's proc manager self.proc.kill(child.exception) def add_endpoint(self, listener, activate=True): """ Adds a listening endpoint to be managed by this ION process. Spawns the listen loop and sets the routing call to synchronize incoming messages here. If this process hasn't been started yet, adds it to the list of listeners to start on startup. @param activate If True (default), start consuming from listener """ if self.proc: listener.routing_call = self._routing_call if self.name: svc_name = "unnamed-service" if self.service is not None and hasattr(self.service, 'name'): svc_name = self.service.name listen_thread_name = "%s-%s-listen-%s" % (svc_name, self.name, len(self.listeners)+1) else: listen_thread_name = "unknown-listener-%s" % (len(self.listeners)+1) listen_thread = self.thread_manager.spawn(listener.listen, thread_name=listen_thread_name, activate=activate) listen_thread.proc._glname = "ION Proc listener %s" % listen_thread_name self._listener_map[listener] = listen_thread self.listeners.append(listener) else: self._startup_listeners.append(listener) def remove_endpoint(self, listener): """ Removes a listening endpoint from management by this ION process. If the endpoint is unknown to this ION process, raises an error. @return The PyonThread running the listen loop, if it exists. You are responsible for closing it when appropriate. """ if listener in self.listeners: self.listeners.remove(listener) return self._listener_map.pop(listener) elif listener in self._startup_listeners: self._startup_listeners.remove(listener) return None else: raise IonProcessError("Cannot remove unrecognized listener: %s" % listener) def target(self, *args, **kwargs): """ Entry point for the main process greenlet. Setup the base properties for this process (mainly the control thread). """ if self.name: threading.current_thread().name = "%s-target" % self.name # start time self._start_time = get_ion_ts_millis() self._proc_interval_num = self._start_time / <API key> # spawn control flow loop self._ctrl_thread = self.thread_manager.spawn(self._control_flow) self._ctrl_thread.proc._glname = "ION Proc CL %s" % self.name # wait on control flow loop, heartbeating as appropriate while not self._ctrl_thread.ev_exit.wait(timeout=self._heartbeat_secs): hbst = self.heartbeat() if not all(hbst): log.warn("Heartbeat status for process %s returned %s", self, hbst) if self._heartbeat_stack is not None: stack_out = "".join(traceback.format_list(self._heartbeat_stack)) else: stack_out = "N/A" #raise PyonHeartbeatError("Heartbeat failed: %s, stacktrace:\n%s" % (hbst, stack_out)) log.warn("Heartbeat failed: %s, stacktrace:\n%s", hbst, stack_out) # this is almost a no-op as we don't fall out of the above loop without # exiting the ctrl_thread, but having this line here makes testing much easier. self._ctrl_thread.join() def _routing_call(self, call, context, *callargs, **callkwargs): """ Endpoints call into here to synchronize across the entire IonProcess. Returns immediately with an AsyncResult that can be waited on. Calls are made by the loop in _control_flow. We pass in the calling greenlet so exceptions are raised in the correct context. @param call The call to be made within this ION processes' calling greenlet. @param callargs The keyword args to pass to the call. @param context Optional process-context (usually the headers of the incoming call) to be set. Process-context is greenlet-local, and since we're crossing greenlet boundaries, we must set it again in the ION process' calling greenlet. """ ar = AsyncResult() if len(callargs) == 0 and len(callkwargs) == 0: log.trace("_routing_call got no arguments for the call %s, check your call's parameters", call) self._ctrl_queue.put((greenlet.getcurrent(), ar, call, callargs, callkwargs, context)) return ar def has_pending_call(self, ar): """ Returns true if the call (keyed by the AsyncResult returned by _routing_call) is still pending. """ for _, qar, _, _, _, _ in self._ctrl_queue.queue: if qar == ar: return True return False def <API key>(self, ar): """ Cancels a pending call (keyed by the AsyncResult returend by _routing_call). @return True if the call was truly pending. """ if self.has_pending_call(ar): ar.set(False) return True return False def <API key>(self): """ Signal the control flow thread that it needs to abort processing, likely due to a timeout. """ self._ctrl_thread.proc.kill(exception=<API key>, block=False) def <API key>(self, ar): """ Either cancels a future pending call, or aborts the current processing if the given AR is unset. The pending call is keyed by the AsyncResult returned by _routing_call. """ if not self.<API key>(ar) and not ar.ready(): self.<API key>() def _control_flow(self): """ Entry point for process control thread of execution. This method is run by the control greenlet for each ION process. Listeners attached to the process, either RPC Servers or Subscribers, synchronize calls to the process by placing call requests into the queue by calling _routing_call. This method blocks until there are calls to be made in the synchronized queue, and then calls from within this greenlet. Any exception raised is caught and re-raised in the greenlet that originally scheduled the call. If successful, the AsyncResult created at scheduling time is set with the result of the call. """ svc_name = getattr(self.service, "name", "unnamed-service") if self.service else "unnamed-service" proc_id = getattr(self.service, "id", "unknown-pid") if self.service else "unknown-pid" if self.name: threading.current_thread().name = "%s-%s" % (svc_name, self.name) thread_base_name = threading.current_thread().name self._ready_control.set() for calltuple in self._ctrl_queue: calling_gl, ar, call, callargs, callkwargs, context = calltuple request_id = (context or {}).get("request-id", None) if request_id: threading.current_thread().name = thread_base_name + "-" + str(request_id) #log.debug("control_flow making call: %s %s %s (has context: %s)", call, callargs, callkwargs, context is not None) res = None start_proc_time = get_ion_ts_millis() self._record_proc_time(start_proc_time) # check context for expiration if context is not None and 'reply-by' in context: if start_proc_time >= int(context['reply-by']): log.info("control_flow: attempting to process message already exceeding reply-by, ignore") # raise a timeout in the calling thread to allow endpoints to continue processing e = IonTimeout("Reply-by time has already occurred (reply-by: %s, op start time: %s)" % (context['reply-by'], start_proc_time)) calling_gl.kill(exception=e, block=False) continue # If ar is set, means it is cancelled if ar.ready(): log.info("control_flow: attempting to process message that has been cancelled, ignore") continue init_db_stats() try: with self.service.push_context(context), \ self.service.container.context.push_context(context): self._ctrl_current = ar res = call(*callargs, **callkwargs) except <API key>: # endpoint layer takes care of response as it's the one that caused this log.debug("Operation interrupted") pass except Exception as e: if self._log_call_exception: log.exception("PROCESS exception: %s" % e.message) # Raise the exception in the calling greenlet. # Try decorating the args of the exception with the true traceback - # this should be reported by ThreadManager._child_failed exc = PyonThreadTraceback("IonProcessThread _control_flow caught an exception " "(call: %s, *args %s, **kwargs %s, context %s)\n" "True traceback captured by IonProcessThread' _control_flow:\n\n%s" % ( call, callargs, callkwargs, context, traceback.format_exc())) e.args = e.args + (exc,) if isinstance(e, (TypeError, IonException)): # Pass through known process exceptions, in particular IonException calling_gl.kill(exception=e, block=False) else: # Otherwise, wrap unknown, forward and hopefully we can continue on our way self._errors.append((call, callargs, callkwargs, context, e, exc)) log.warn(exc) log.warn("Attempting to continue...") # Note: Too large exception string will crash the container (when passed on as msg header). exception_str = str(exc) if len(exception_str) > 10000: exception_str = ( "Exception string representation too large. " "Begin and end of the exception:\n" + exception_str[:2000] + "\n...\n" + exception_str[-2000:] ) calling_gl.kill(exception=ContainerError(exception_str), block=False) finally: try: # Compute statistics self._compute_proc_stats(start_proc_time) db_stats = get_db_stats() if db_stats: if self.<API key> > 0 and db_stats.get("count.all", 0) >= self.<API key>: stats_str = ", ".join("{}={}".format(k, db_stats[k]) for k in sorted(db_stats.keys())) log.warn("PROC_OP '%s.%s' EXCEEDED DB THRESHOLD. stats=%s", svc_name, call.__name__, stats_str) elif self._log_call_dbstats: stats_str = ", ".join("{}={}".format(k, db_stats[k]) for k in sorted(db_stats.keys())) log.info("PROC_OP '%s.%s' DB STATS: %s", svc_name, call.__name__, stats_str) clear_db_stats() if stats_callback: stats_callback(proc_id=proc_id, proc_name=self.name, svc=svc_name, op=call.__name__, request_id=request_id, context=context, db_stats=db_stats, proc_stats=self.time_stats, result=res, exc=None) except Exception: log.exception("Error computing process call stats") self._ctrl_current = None threading.current_thread().name = thread_base_name # Set response in AsyncEvent of caller (endpoint greenlet) ar.set(res) def _record_proc_time(self, cur_time): """ Keep the _proc_time of the prior and prior-prior intervals for stats computation """ cur_interval = cur_time / <API key> if cur_interval == self._proc_interval_num: # We're still in the same interval - no update pass elif cur_interval-1 == self._proc_interval_num: # Record the stats from the prior interval self._proc_interval_num = cur_interval self._proc_time_prior2 = self._proc_time_prior self._proc_time_prior = self._proc_time elif cur_interval-1 > self._proc_interval_num: # We skipped an entire interval - everything is prior2 self._proc_interval_num = cur_interval self._proc_time_prior2 = self._proc_time self._proc_time_prior = self._proc_time def _compute_proc_stats(self, start_proc_time): cur_time = get_ion_ts_millis() self._record_proc_time(cur_time) proc_time = cur_time - start_proc_time self._proc_time += proc_time def start_listeners(self): """ Starts all listeners in managed greenlets. Usually called by the ProcManager, unless using IonProcess manually. """ try: # disable normal error reporting, this method should only be called from startup self.thread_manager.<API key> = None # spawn all listeners in startup listeners (from initializer, or added later) for listener in self._startup_listeners: self.add_endpoint(listener) with Timeout(seconds=CFG.get_safe('container.messaging.timeout.start_listener', 30)): gevent.wait([x.get_ready_event() for x in self.listeners]) except Timeout: # remove failed endpoints before reporting failure above for listener, proc in self._listener_map.iteritems(): if proc.proc.dead: log.info("removed dead listener: %s", listener) self.listeners.remove(listener) self.thread_manager.children.remove(proc) raise IonProcessError("start_listeners did not complete in expected time") finally: self.thread_manager.<API key> = self._child_failed def _notify_stop(self): """ Called when the process is about to be shut down. Instructs all listeners to close, puts a StopIteration into the synchronized queue, and waits for the listeners to close and for the control queue to exit. """ for listener in self.listeners: try: listener.close() except Exception as ex: tb = traceback.format_exc() log.warn("Could not close listener, attempting to ignore: %s\nTraceback:\n%s", ex, tb) self._ctrl_queue.put(StopIteration) # wait_children will join them and then get() them, which may raise an exception if any of them # died with an exception. self.thread_manager.wait_children(30) PyonThread._notify_stop(self) # run the cleanup method if we have one if self._cleanup_method is not None: try: self._cleanup_method(self) except Exception as ex: log.warn("Cleanup method error, attempting to ignore: %s\nTraceback: %s", ex, traceback.format_exc()) def get_ready_event(self): """ Returns an Event that is set when the control greenlet is up and running. """ return self._ready_control class <API key>(PyonThreadManager): def _create_thread(self, target=None, **kwargs): return IonProcessThread(target=target, heartbeat_secs=self.heartbeat_secs, **kwargs) # Process type variants class StandaloneProcess(BaseService): """ A process is an ION process of type "standalone" that has an incoming messaging attachment for the process and operations as defined in a service YML. """ process_type = "standalone" class SimpleProcess(BaseService): """ A simple process is an ION process of type "simple" that has no incoming messaging attachment. """ process_type = "simple" class ImmediateProcess(BaseService): """ An immediate process is an ION process of type "immediate" that does its action in the on_init and on_start hooks, and that it terminated immediately after completion. Has no messaging attachment. """ process_type = "immediate" class StreamProcess(BaseService): """ Base class for a stream process. Such a process handles a sequence of otherwise unconstrained messages, resulting from a subscription. There are no operations. """ process_type = "stream_process" def call_process(self, message, stream_route, stream_id): """ Handles pre-processing of packet and process work """ self.process(message) def process(self, message): """ Process a message as arriving based on a subscription. """ pass # Process helpers def get_ion_actor_id(process): """Given an ION process, return the ion-actor-id from the context, if set and present""" ion_actor_id = None if process: ctx = process.get_context() ion_actor_id = ctx.get(MSG_HEADER_ACTOR, None) if ctx else None return ion_actor_id def <API key>(stats_cb): """ Sets a callback function (hook) to push stats after a process operation call. """ global stats_callback if stats_cb is None: pass elif stats_callback: log.warn("Stats callback already defined") stats_callback = stats_cb
# 98Fmplayer (beta) PC-98 FM driver emulation (very early version) ![gtk screenshot](/img/screenshot_gtk.png?raw=true) ![gtk toneviewer screenshot](/img/screenshot_gtk.toneview.png?raw=true) ![gtk config screenshot](/img/screenshot_gtk.config.png?raw=true) ![w2k screenshot](/img/screenshotw2k.png?raw=true) *If you are just annoyed by some specific bugs in PMDWin, [patched PMDWin](https://github.com/takamichih/pmdwinbuild) might have less bugs and more features than this.* ## Current status: * Supported formats: PMD, FMP(PLAY6) * PMD: FM, SSG, Rhythm, ADPCM, PPZ8(partially) supported; PPS, P86 not supported yet * FMP: FM, SSG, Rhythm, ADPCM, PPZ8, PDZF supported * This is just a byproduct of reverse-engineering formats, and its emulation is much worse than PMDWin, WinFMP * FM always generated in 55467Hz (closest integer to 7987200 / 144), SSG always generated in 249600Hz and downsampled with sinc filter (Never linear interpolates harmonics-rich signal like square wave) * FM generation bit-perfect with actual OPNA/OPN3 chip under limited conditions including stereo output when 4 <= ALG (Envelope is not bit-perfect yet, attack is bit-perfect only when AR >= 21) * SSGEG, Hardware LFO not supported * PPZ8: support nearest neighbor, linear and sinc interpolation * ADPCM: inaccurate (actual YM2608 seems to decode ADPCM at lower samplerate/resolution than any YM2608 emulator around, but I still couldn't get my YM2608 work with the DRAM) ## Installation/Usage (not very usable yet) gtk Uses gtk3, pulseaudio/jack/alsa $ cd gtk $ autoreconf -i $ ./configure $ make $ ./98fmplayer Reads drum sample from `$HOME/.local/share/98fmplayer/ym2608_adpcm_rom.bin` (same format as MAME). win32 Releases: https://github.com/takamichih/fmplayer/releases/ Uses MinGW-w64 to compile. $ cd win32/x86 $ make Reads drum sample from the directory in which `98fmplayer.exe` is placed. Uses DirectSound (WinMM if there is no DirectSound) to output sound. This works on Windows 2000, so it is theoretically possible to run this on a real PC-98. (But it was too heavy for my PC-9821V12 which only has P5 Pentium 120MHz, or on PC-9821Ra300 with P6 Mendocino Celeron 300MHz)
""" Module for listing commands and help. """ from basemodule import BaseModule, BaseCommandContext from alternatives import _ class HelpContext(BaseCommandContext): def cmd_list(self, argument): """List commands""" arg = argument.lower() index = self.bot.help_index public = "public commands -- %s" % " ".join(index['public']) private = "private commands -- %s" % " ".join(index['private']) if 'all' in arg or 'both' in arg: output = "\n".join((public, private)) elif 'pub' in arg or self.target.startswith(' output = public elif 'priv' in arg or not self.target.startswith(' output = private else: # we shouldn't be here self.logger.error("cmd_list") return self.send(self.target, output) def cmd_modules(self, argument): """List active modules""" index = self.bot.help_index output = "active modules -- %s" % " ".join(index['modules'].keys()) self.send(self.target, output) def cmd_help(self, argument): """Get help on a command or module""" arg = argument.lower() index = self.bot.help_index target = self.target args = arg.split() if not args: s = "usage: help <command> [public|private] / help module <module>" self.send(target, s) elif args[0] == 'module': args.pop(0) if not args: self.send(target, "usage: help module <module>") else: help_item = index['modules'].get(args[0]) if help_item: self.send(target, help_item['summary']) else: self.send(target, _("No help for %s"), args[0]) else: args.append("") cmd = args.pop(0) cmd_type = args.pop(0) if 'pu' in cmd_type or self.target.startswith(' cmd_type = 'public' elif 'pr' in cmd_type or not self.target.startswith(' cmd_type = 'private' else: # we shouldn't be here self.logger.error("cmd_list") return help_item = index[cmd_type].get(cmd) if help_item: self.send(target, index[cmd_type][cmd]['summary']) else: self.send(target, _("No help for %s"), cmd) class HelpModule(BaseModule): context_class = HelpContext module = HelpModule
cask 'feeder' do version '3.6.8' sha256 '<SHA256-like>' url "https://reinventedsoftware.com/feeder/downloads/Feeder_#{version}.dmg" appcast "https://reinventedsoftware.com/feeder/downloads/Feeder#{version.major}.xml" name 'Feeder' homepage 'https://reinventedsoftware.com/feeder/' app "Feeder #{version.major}.app" end
{-# LANGUAGE TemplateHaskell, QuasiQuotes, OverloadedStrings #-} module Handler.Root where import Foundation -- This is a handler function for the GET request method on the RootR -- resource pattern. All of your resource patterns are defined in -- config/routes -- The majority of the code you will write in Yesod lives in these handler -- functions. You can spread them across multiple files if you are so -- inclined, or create a single monolithic file. getRootR :: Handler RepHtml getRootR = do defaultLayout $ do h2id <- lift newIdent setTitle "TierList homepage" $(widgetFile "homepage")
<?php namespace MtMail\Factory; use Interop\Container\ContainerInterface; use MtMail\ComposerPlugin\DefaultHeaders; class <API key> { public function __invoke(ContainerInterface $serviceLocator) { if (!method_exists($serviceLocator, 'configure')) { $serviceLocator = $serviceLocator->getServiceLocator(); } $config = $serviceLocator->get('Configuration'); $plugin = new DefaultHeaders(); if (isset($config['mt_mail']['default_headers'])) { $plugin->setHeaders($config['mt_mail']['default_headers']); } return $plugin; } }
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) Try If disposing AndAlso components IsNot Nothing Then components.Dispose() End If Finally MyBase.Dispose(disposing) End Try End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button() Me.DataGridView1 = New System.Windows.Forms.DataGridView() Me.Table1TableAdapter1 = New WindowsApplication1.<API key>.Table1TableAdapter() CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(52, 218) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(75, 23) Me.Button1.TabIndex = 1 Me.Button1.Text = "Button1" Me.Button1.<API key> = True ' 'DataGridView1 ' Me.DataGridView1.<API key> = True Me.DataGridView1.<API key> = System.Windows.Forms.<API key>.AutoSize Me.DataGridView1.Location = New System.Drawing.Point(52, 25) Me.DataGridView1.Name = "DataGridView1" Me.DataGridView1.Size = New System.Drawing.Size(417, 162) Me.DataGridView1.TabIndex = 2 ' 'Table1TableAdapter1 ' Me.Table1TableAdapter1.ClearBeforeFill = True ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(522, 344) Me.Controls.Add(Me.DataGridView1) Me.Controls.Add(Me.Button1) Me.Name = "Form1" Me.Text = "Form1" CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) End Sub Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents DataGridView1 As System.Windows.Forms.DataGridView Friend WithEvents Table1TableAdapter1 As WindowsApplication1.<API key>.Table1TableAdapter End Class
// This file was procedurally generated from the following sources: // - src/async-generators/<API key>.case // - src/async-generators/syntax/<API key>.template throw "Test262: This statement should not be evaluated."; var C = class { async *gen() { void yi\u0065ld; }};
#ifndef HSFC_PORTABLE_H #define HSFC_PORTABLE_H #include <iostream> #include <string> #include <vector> #include <set> #include <memory> #include <iterator> #include <algorithm> #include <stdint.h> #include <boost/assert.hpp> #include <boost/exception/all.hpp> #include <boost/scoped_ptr.hpp> #include <boost/shared_ptr.hpp> #include <boost/serialization/serialization.hpp> #include <boost/serialization/utility.hpp> #include <boost/serialization/vector.hpp> #include <boost/serialization/map.hpp> #include <boost/serialization/set.hpp> #include <boost/serialization/shared_ptr.hpp> #include <boost/serialization/access.hpp> #include <hsfc/hsfcexception.h> #include <hsfc/impl/fwd_decl.h> namespace HSFC { class PortableState { public: PortableState(); PortableState(const State& state); PortableState(const PortableState& other); PortableState& operator=(const PortableState& other); bool operator==(const PortableState& other) const; bool operator!=(const PortableState& other) const; bool operator<(const PortableState& other) const; std::size_t hash_value() const; private: friend class State; friend class boost::serialization::access; int round_; int currentstep_; std::set<std::pair<int,int> > relationset_; template<typename Archive> void serialize(Archive& ar, const unsigned int version); }; std::size_t hash_value(const PortableState& ps); /* Can be used as a key in boost::unordered_* */ template<typename Archive> void PortableState::serialize(Archive& ar, const unsigned int version) { ar & round_; ar & currentstep_; ar & relationset_; } class PortablePlayer { public: PortablePlayer(); PortablePlayer(const Player& player); PortablePlayer(const PortablePlayer& other); PortablePlayer& operator=(const PortablePlayer& other); bool operator==(const PortablePlayer& other) const; bool operator!=(const PortablePlayer& other) const; bool operator<(const PortablePlayer& other) const; std::size_t hash_value() const; private: friend class Player; friend class boost::serialization::access; template<typename Archive> void serialize(Archive& ar, const unsigned int version); unsigned int roleid_; }; template<typename Archive> void PortablePlayer::serialize(Archive& ar, const unsigned int version) { ar & roleid_; } std::size_t hash_value(const PortablePlayer& pp); /* Can be used as a key in boost::unordered_* */ class PortableMove { public: PortableMove(); PortableMove(const Move& move); PortableMove(const PortableMove& other); PortableMove& operator=(const PortableMove& other); bool operator==(const PortableMove& other) const; bool operator!=(const PortableMove& other) const; bool operator<(const PortableMove& other) const; std::size_t hash_value() const; private: friend class Move; friend class boost::serialization::access; template<typename Archive> void serialize(Archive& ar, const unsigned int version); int RoleIndex_; std::string Text_; int RelationIndex_; int ID_; }; template<typename Archive> void PortableMove::serialize(Archive& ar, const unsigned int version) { ar & RoleIndex_; ar & Text_; ar & RelationIndex_; ar & ID_; } std::size_t hash_value(const PortableMove& pm); /* Can be used as a key in boost::unordered_* */ struct FromPortable { public: FromPortable(Game& game); JointMove operator()(const PortableJointMove& pjm); JointGoal operator()(const PortableJointGoal& pjg); PlayerMove operator()(const PortablePlayerMove& ppm); PlayerMove operator()(const std::pair<const PortablePlayer, PortableMove>& ppm); PlayerGoal operator()(const PortablePlayerGoal& ppg); PlayerGoal operator()(const std::pair<const PortablePlayer, unsigned int>& ppg); Player operator()(const PortablePlayer& pp); Move operator()(const PortableMove& pm); State operator()(const PortableState& ps); private: Game& game_; }; inline FromPortable::FromPortable(Game& game) : game_(game) { } inline JointMove FromPortable::operator()(const PortableJointMove& pjm) { JointMove jm; std::transform(pjm.begin(), pjm.end(), std::inserter(jm,jm.begin()),*this); return jm; } inline JointGoal FromPortable::operator()(const PortableJointGoal& pjg) { JointGoal jg; std::transform(pjg.begin(), pjg.end(), std::inserter(jg,jg.begin()),*this); return jg; } inline PlayerMove FromPortable::operator()(const PortablePlayerMove& ppm) { return PlayerMove(Player(game_, ppm.first), Move(game_,ppm.second)); } inline PlayerMove FromPortable::operator()(const std::pair<const PortablePlayer, PortableMove>& ppm) { return PlayerMove(Player(game_, ppm.first), Move(game_,ppm.second)); } inline PlayerGoal FromPortable::operator()(const PortablePlayerGoal& ppg) { return PlayerGoal(Player(game_, ppg.first), ppg.second); } inline PlayerGoal FromPortable::operator()(const std::pair<const PortablePlayer, unsigned int>& ppg) { return PlayerGoal(Player(game_, ppg.first), ppg.second); } inline Player FromPortable::operator()(const PortablePlayer& pp) { return Player(game_, pp); } inline Move FromPortable::operator()(const PortableMove& pm) { return Move(game_, pm); } inline State FromPortable::operator()(const PortableState& ps) { return State(game_, ps); } struct ToPortable { public: ToPortable(); ToPortable(Game& game); PortableJointMove operator()(const JointMove& jm); PortableJointGoal operator()(const JointGoal& jg); PortablePlayerMove operator()(const PlayerMove& ppm); PortablePlayerGoal operator()(const PlayerGoal& ppg); PortablePlayer operator()(const Player& pp); PortableMove operator()(const Move& pm); PortableState operator()(const State& ps); }; inline ToPortable::ToPortable(){ } inline ToPortable::ToPortable(Game& game){ } inline PortableJointMove ToPortable::operator()(const JointMove& jm) { PortableJointMove pjm; std::copy(jm.begin(), jm.end(), std::inserter(pjm,pjm.begin())); return pjm; } inline PortableJointGoal ToPortable::operator()(const JointGoal& jg) { PortableJointGoal pjg; std::copy(jg.begin(), jg.end(), std::inserter(pjg,pjg.begin())); return pjg; } inline PortablePlayerMove ToPortable::operator()(const PlayerMove& pm) { return PortablePlayerMove(pm); } inline PortablePlayerGoal ToPortable::operator()(const PlayerGoal& pg) { return PortablePlayerGoal(pg); } inline PortablePlayer ToPortable::operator()(const Player& p) { return PortablePlayer(p); } inline PortableMove ToPortable::operator()(const Move& m) { return PortableMove(m); } inline PortableState ToPortable::operator()(const State& s) { return PortableState(s); } }; /* namespace HSFC */ #endif // HSFC_PORTABLE_H
#!/usr/bin/env python #modification, are permitted provided that the following conditions are met: # and/or other materials provided with the distribution. #ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED #WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE #ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES #(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; #LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND #ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT #(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS #SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #The views and conclusions contained in the software and documentation are those #of the authors and should not be interpreted as representing official policies, #either expressed or implied, of the FreeBSD Project. import sys from PyQt4 import QtGui from ui.preprocessDialog import PreprocessDialog def main(): app = QtGui.QApplication(sys.argv) window=PreprocessDialog() window.show() sys.exit(app.exec_()) if __name__ == '__main__': main()
# Customize below path information #TET_INSTALL_PATH=/scratchbox/TETware CURRENT_USER=`echo $HOME` TET_INSTALL_PATH=$CURRENT_USER/sbs/TETware # temporary fix for SPRC if [ "$TET_ROOT_DIR" != "" ]; then TET_INSTALL_PATH=$TET_ROOT_DIR fi TET_SIMUL_PATH=$TET_INSTALL_PATH/tetware-simulator TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target TET_MOUNTED_PATH=/mnt/nfs/sbs/TETware/tetware-target #TET_MOUNTED_PATH=/opt/home/root/tmp/sbs/TETware/tetware-target #MACHINE=`echo $SBOX_UNAME_MACHINE` MACHINE=`echo $DEB_BUILD_ARCH_ABI` if [ $MACHINE = "gnu" ] # SBS i386 then export ARCH=simulator export TET_ROOT=$TET_SIMUL_PATH elif [ $MACHINE = "gnueabi" ] # SBS ARM then export ARCH=target export TET_ROOT=$TET_TARGET_PATH else export ARCH=target export TET_ROOT=$TET_MOUNTED_PATH fi export PATH=$TET_ROOT/bin:$PATH export LD_LIBRARY_PATH=$TET_ROOT/lib/tet3:$LD_LIBRARY_PATH set $(pwd) export TET_SUITE_ROOT=$1 set $(date +%y%m%d_%H%M%S) FILE_NAME_EXTENSION=$1
<!DOCTYPE HTML PUBLIC "- <!--NewPage <HTML> <HEAD> <!-- Generated by javadoc (build 1.6.0_22) on Tue Mar 08 15:19:00 PST 2011 --> <TITLE> Uses of Class com.perforce.p4java.ant.tasks.ServerTask.GlobalOption (P4Ant) </TITLE> <META NAME="date" CONTENT="2011-03-08"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../../stylesheet.css" TITLE="Style"> <SCRIPT type="text/javascript"> function windowTitle() { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="Uses of Class com.perforce.p4java.ant.tasks.ServerTask.GlobalOption (P4Ant)"; } } </SCRIPT> <NOSCRIPT> </NOSCRIPT> </HEAD> <BODY BGCOLOR="white" onload="windowTitle();"> <HR> <A NAME="navbar_top"></A> <A HREF="#skip-navbar_top" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_top_firstrow"></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../com/perforce/p4java/ant/tasks/ServerTask.GlobalOption.html" title="class in com.perforce.p4java.ant.tasks"><FONT CLASS="NavBarFont1"><B>Class</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Use</B></FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> &nbsp;PREV&nbsp; &nbsp;NEXT</FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../../index.html?com/perforce/p4java/ant/tasks//class-useServerTask.GlobalOption.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="ServerTask.GlobalOption.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <! if(window==top) { document.writeln('<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } </SCRIPT> <NOSCRIPT> <A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_top"></A> <HR> <CENTER> <H2> <B>Uses of Class<br>com.perforce.p4java.ant.tasks.ServerTask.GlobalOption</B></H2> </CENTER> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> Packages that use <A HREF="../../../../../../com/perforce/p4java/ant/tasks/ServerTask.GlobalOption.html" title="class in com.perforce.p4java.ant.tasks">ServerTask.GlobalOption</A></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD><A HREF="#com.perforce.p4java.ant.tasks"><B>com.perforce.p4java.ant.tasks</B></A></TD> <TD> The Perforce tasks implement Perforce commands using the Perforce Java API.&nbsp;</TD> </TR> </TABLE> &nbsp; <P> <A NAME="com.perforce.p4java.ant.tasks"></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> Uses of <A HREF="../../../../../../com/perforce/p4java/ant/tasks/ServerTask.GlobalOption.html" title="class in com.perforce.p4java.ant.tasks">ServerTask.GlobalOption</A> in <A HREF="../../../../../../com/perforce/p4java/ant/tasks/package-summary.html">com.perforce.p4java.ant.tasks</A></FONT></TH> </TR> </TABLE> &nbsp; <P> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="<API key>"> <TH ALIGN="left" COLSPAN="2">Fields in <A HREF="../../../../../../com/perforce/p4java/ant/tasks/package-summary.html">com.perforce.p4java.ant.tasks</A> with type parameters of type <A HREF="../../../../../../com/perforce/p4java/ant/tasks/ServerTask.GlobalOption.html" title="class in com.perforce.p4java.ant.tasks">ServerTask.GlobalOption</A></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>protected &nbsp;java.util.List&lt;<A HREF="../../../../../../com/perforce/p4java/ant/tasks/ServerTask.GlobalOption.html" title="class in com.perforce.p4java.ant.tasks">ServerTask.GlobalOption</A>&gt;</CODE></FONT></TD> <TD><CODE><B>ServerTask.</B><B><A HREF="../../../../../../com/perforce/p4java/ant/tasks/ServerTask.html#globaloptions">globaloptions</A></B></CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Collection of globaloptions (name-value pairs) contained in the "globaloption" nested elements.</TD> </TR> </TABLE> &nbsp; <P> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="<API key>"> <TH ALIGN="left" COLSPAN="2">Methods in <A HREF="../../../../../../com/perforce/p4java/ant/tasks/package-summary.html">com.perforce.p4java.ant.tasks</A> that return <A HREF="../../../../../../com/perforce/p4java/ant/tasks/ServerTask.GlobalOption.html" title="class in com.perforce.p4java.ant.tasks">ServerTask.GlobalOption</A></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>&nbsp;<A HREF="../../../../../../com/perforce/p4java/ant/tasks/ServerTask.GlobalOption.html" title="class in com.perforce.p4java.ant.tasks">ServerTask.GlobalOption</A></CODE></FONT></TD> <TD><CODE><B>ServerTask.</B><B><A HREF="../../../../../../com/perforce/p4java/ant/tasks/ServerTask.html#createGlobalOption()">createGlobalOption</A></B>()</CODE> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This method is called by an Ant factory method to instantiates a collection of "globaloption" nested elements.</TD> </TR> </TABLE> &nbsp; <P> <HR> <A NAME="navbar_bottom"></A> <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="<API key>"></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../com/perforce/p4java/ant/tasks/ServerTask.GlobalOption.html" title="class in com.perforce.p4java.ant.tasks"><FONT CLASS="NavBarFont1"><B>Class</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Use</B></FONT>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> &nbsp;PREV&nbsp; &nbsp;NEXT</FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../../index.html?com/perforce/p4java/ant/tasks//class-useServerTask.GlobalOption.html" target="_top"><B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="ServerTask.GlobalOption.html" target="_top"><B>NO FRAMES</B></A> &nbsp; &nbsp;<SCRIPT type="text/javascript"> <! if(window==top) { document.writeln('<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } </SCRIPT> <NOSCRIPT> <A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_bottom"></A> <HR> <i>Copyright (c) 2010 Perforce Software. All rights reserved.</i> </BODY> </HTML>
L.CommunistWorker = L.AbstractWorker.extend({ statics: { // number of web workers, not using web workers when falsy NUM_WORKERS: 2 }, initialize: function (workerFunc) { this.workerFunc = workerFunc; }, onAdd: function (map) { this._workers = L.CommunistWorker.createWorkers(this.workerFunc); }, onRemove: function (map) { if (this._workers) { // TODO do not close when other layers are still using the static instance //this._workers.close(); } }, process: function(tile, callback) { if (this._workers){ tile._worker = this._workers.data(tile.datum).then(function(parsed) { if (tile._worker) { tile._worker = null; tile.parsed = parsed; tile.datum = null; callback(null, tile); } else { // tile has been unloaded, don't continue with adding //console.log('worker aborted ' + tile.key); } }); } else { callback(null, tile); } }, abort: function(tile) { if (tile._worker) { // TODO abort worker, would need to recreate after close //tile._worker.close(); tile._worker = null; } } }); L.communistWorker = function (workerFunc) { return new L.CommunistWorker(workerFunc); }; L.extend(L.CommunistWorker, { createWorkers: function(workerFunc) { if ( L.CommunistWorker.NUM_WORKERS && typeof Worker === "function" && typeof communist === "function" && !("workers" in L.CommunistWorker)) { L.CommunistWorker.workers = communist({ //data : L.TileLayer.Vector.parseData data : workerFunc }, L.CommunistWorker.NUM_WORKERS); } return L.CommunistWorker.workers; } });
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace nora.clara.machine { public enum Event { OPEN_REQUEST, ACTION_REQUEST, DEATH_REQUEST, CONNECTED_TO_STEAM, <API key>, <API key>, <API key>, <API key>, WELCOMED, JOINED_CHAT, CREATED_LOBBY, LEFT_LOBBY, PLAYER_JOINED, EMPTIED, LOBBY_READY, LOBBY_NOT_READY, GOT_APP_TICKET, GOT_AUTH, GOT_SESSION, GOT_TV, <API key>, DENIED_TV, SERVER_RUNNING, <API key>, GAME_SERVER_QUIT, } }
package com.jme3.gde.core.filters.impl; import com.jme3.gde.core.filters.AbstractFilterNode; import com.jme3.gde.core.filters.FilterNode; import com.jme3.post.Filter; import com.jme3.water.WaterFilter; import org.openide.loaders.DataObject; import org.openide.nodes.Node; import org.openide.nodes.Sheet; @org.openide.util.lookup.ServiceProvider(service = FilterNode.class) public class JmeWaterFilter extends AbstractFilterNode { public JmeWaterFilter() { } public JmeWaterFilter(WaterFilter filter, DataObject object, boolean readOnly) { super(filter); this.dataObject = object; this.readOnly = readOnly; } @Override protected Sheet createSheet() { Sheet sheet = super.createSheet(); Sheet.Set set = Sheet.createPropertiesSet(); set.setDisplayName("Water"); set.setName("Water"); WaterFilter obj = (WaterFilter) filter; if (obj == null) { return sheet; } createFields(WaterFilter.class, set, obj); sheet.put(set); return sheet; } @Override public Class<?> <API key>() { return WaterFilter.class; } @Override public Node[] createNodes(Object key, DataObject dataObject, boolean readOnly) { return new Node[]{new JmeWaterFilter((WaterFilter) key, dataObject, readOnly)}; } }
<?php namespace Nether\Object\Meta; use Attribute; use Nether\Object\Prototype\AttributeInterface; use Nether\Object\Prototype\PropertyAttributes; #[Attribute(Attribute::TARGET_PROPERTY)] class PropertyOrigin implements AttributeInterface { /*// @date 2021-08-05 @related Nether\Object\Prototype::__Construct when attached to a class property with a single string argument that will tell the prototype object to pull the data stored in the arguement and to put it into the property this is attached to. //*/ public string $Name; public function __Construct(string $Name) { $this->Name = $Name; return; } public function <API key>(PropertyAttributes $Attrib): static { $Attrib->Origin = $this->Name; return $this; } }
#!/usr/bin/perl # Adduser script # Get user data from signup database # Create PAM+Satan user # Insert user data into adduser database # Assign servers to user # Create containers with lxc-add remote script use warnings; use strict; use Readonly; use FindBin qw($Bin); use File::Basename qw(basename); use POSIX qw(isdigit); use DBI; use Getopt::Long; use Smart::Comments; # Server ID's Readonly my $WEB_SERVER_ID => 1; Readonly my $APP_SERVER_ID => 1; Readonly my $DEV_SERVER_ID => 1; # Satan connection params Readonly my $SATAN_ADDR => '10.101.0.5'; Readonly my $SATAN_PORT => '1600'; Readonly my $SATAN_KEY => '/etc/satan/key'; Readonly my $SATAN_BIN => '/usr/local/bin/satan'; # SSH params Readonly my $SSH_BIN => '/usr/bin/ssh'; Readonly my $SSH_ADD_KEY => '/root/.ssh/lxc_add_rsa'; Readonly my $SSH_ADD_COMMAND => '/usr/local/sbin/lxc-add'; # Usage Readonly my $BASENAME => basename($0); Readonly my $USAGE => <<END_OF_USAGE; Adduser script Usage: $BASENAME signup get signup data and create pam user $BASENAME pam --uid <uid> create pam user omitting signup DB $BASENAME container --uid <uid> --server <type> create container of given type END_OF_USAGE # Check configuration -f $SATAN_BIN or die "\$SATAN_BIN ($SATAN_BIN) not found.\n"; -f $SATAN_KEY or die "\$SATAN_KEY ($SATAN_KEY) not found.\n"; -f $SSH_ADD_KEY or die "\$SSH_ADD_KEY ($SSH_ADD_KEY) not found.\n"; # Signup database my %db_signup; $db_signup{dbh} = DBI->connect("dbi:mysql:signup;<API key>=$Bin/config/my.signup.cnf", undef, undef, { RaiseError => 1, AutoCommit => 1 }); $db_signup{get_user} = $db_signup{dbh}->prepare("SELECT * FROM users WHERE status IS NULL LIMIT 1"); $db_signup{del_user} = $db_signup{dbh}->prepare("DELETE FROM users WHERE id=?"); $db_signup{set_status} = $db_signup{dbh}->prepare("UPDATE users SET status=? WHERE id=?"); # Adduser database my %db_adduser; $db_adduser{dbh} = DBI->connect("dbi:mysql:adduser;<API key>=$Bin/config/my.adduser.cnf", undef, undef, { RaiseError => 1, AutoCommit => 1 }); $db_adduser{add_user} = $db_adduser{dbh}->prepare("INSERT INTO users (uid, user_name, mail, created_at) VALUES(?,?,?, NOW())"); $db_adduser{get_user} = $db_adduser{dbh}->prepare("SELECT * FROM users WHERE uid=?"); $db_adduser{add_credentials} = $db_adduser{dbh}->prepare("INSERT INTO credentials(uid, satan_key, pam_passwd, pam_shadow, user_password, user_password_p) VALUES(?,?,?,?,?,?)"); $db_adduser{get_credentials} = $db_adduser{dbh}->prepare("SELECT * FROM credentials WHERE uid=?"); $db_adduser{add_container} = $db_adduser{dbh}->prepare("INSERT INTO containers(uid, server_type, server_no) VALUES(?,?,?)"); $db_adduser{get_container} = $db_adduser{dbh}->prepare("SELECT server_no FROM containers WHERE uid=? AND server_type=? and status is NULL"); $db_adduser{<API key>} = $db_adduser{dbh}->prepare("UPDATE containers SET status=? WHERE uid=? AND server_type=?"); # Get arguments die $USAGE unless @ARGV; my $mode_type = shift or die "Mode not specified. Use 'signup', 'container' or 'pam'.\n"; # Get command line arguments my ($opt_uid, $opt_server); GetOptions( 'uid=i' => \$opt_uid, 'server=s' => \$opt_server, ); # SIGNUP MODE # Get 1 user from signup database # Create Pam+Satan user # Store data in adduser database if ($mode_type eq 'signup') { # Get one record from signup database $db_signup{get_user}->execute; # Exit if nothing found my $record_found = $db_signup{get_user}->rows; $record_found or exit; # Get user data my $signup_record = $db_signup{get_user}->fetchall_hashref('user_name'); $signup_record # Get username my @user_names = keys %$signup_record; my $user_name = shift @user_names; $user_name # User record my $user_record = $signup_record->{$user_name}; $user_record # Add PAM+Satan user my $satan_response; eval { $satan_response = satan('admin', 'adduser', $user_name); }; # Satan error if ($@) { my $error_message = $@; chomp $error_message; my $user_id = $user_record->{id}; $db_signup{set_status}->execute($error_message, $user_id); die "Satan error: $@"; } my $uid = $satan_response->{uid} or die "Didn't get uid from satan"; $satan_response # XXX Catch satan error # $db_signup{set_status}->execute($error_message, $user_record->{id}); # Add record to adduser database $db_adduser{add_user}->execute( $uid, $user_record->{user_name}, $user_record->{mail}, ); # Insert user credentials $db_adduser{add_credentials}->execute( $uid, $satan_response->{satan_key}, $satan_response->{pam_passwd}, $satan_response->{pam_shadow}, $satan_response->{user_password}, $satan_response->{user_password_p} ); # Assign servers set_containers($uid); # Remove record from signup database $db_signup{del_user}->execute($user_record->{id}); exit; } # PAM MODE # Create pam and satan user only. if ($mode_type eq 'pam') { # Mandatory arguments defined $opt_uid or die "Uid not specified."; my $uid = $opt_uid; # Get user from adduser database $db_adduser{get_user}->execute($uid); my $user_found = $db_adduser{get_user}->rows; $user_found or die "Uid '$uid' not found in adduser database.\n"; # User record my $user_record = $db_adduser{get_user}->fetchall_hashref('uid')->{$uid}; my $user_name = $user_record->{user_name} or die "User name not found"; # Add PAM+Satan user with predefined uid my $satan_response = satan('admin', 'adduser', $user_name, 'uid', $uid); # Insert user credentials $db_adduser{add_credentials}->execute( $uid, $satan_response->{satan_key}, $satan_response->{pam_passwd}, $satan_response->{pam_shadow}, $satan_response->{user_password}, $satan_response->{user_password_p} ); # Assign servers to user set_containers($uid); exit; } # CONTAINER MODE # Create user container on specified server. # User must exist in adduser database. if ($mode_type eq 'container') { # Mandatory arguments defined $opt_uid or die "Uid not specified."; defined $opt_server or die "Server name not specified."; my $uid = $opt_uid; my $server_type = $opt_server; # Get user from adduser database $db_adduser{get_user}->execute($uid); my $user_found = $db_adduser{get_user}->rows; $user_found or die "Uid '$uid' not found in adduser database.\n"; # User record my $user_record = $db_adduser{get_user}->fetchall_hashref('uid')->{$uid}; my $user_name = $user_record->{user_name} or die "User name not found"; $user_name # Get credentials $db_adduser{get_credentials}->execute($uid); my $credentials_found = $db_adduser{get_credentials}->rows; $credentials_found or die "Uid '$uid' not found in database.\n"; my $credentials = $db_adduser{get_credentials}->fetchall_hashref('uid')->{$uid}; # Get container number $db_adduser{get_container}->execute($uid, $server_type); my $server_found = $db_adduser{get_container}->rows; $server_found or die "Container type '$server_type' not defined for user '$uid'.\n"; my $server_no = $db_adduser{get_container}->fetchrow_arrayref->[0]; isdigit($server_no) or die "Server no '$server_no' not a number.\n"; my $server_name = $server_type . $server_no; # Set SSH command arguments my $command_args = "satan_key $credentials->{satan_key} " . "pam_passwd $credentials->{pam_passwd} " . "pam_shadow $credentials->{pam_shadow} " . "uid $uid " . "user_name $user_name"; $command_args system("$SSH_BIN -i $SSH_ADD_KEY root\@system.$server_name.rootnode.net $SSH_ADD_COMMAND $command_args"); if ($?) { my $error_message = $!; chomp $error_message; $db_adduser{<API key>}->execute($error_message, $uid, $server_type); die "lxc-add failed: $!"; } $db_adduser{<API key>}->execute('OK', $uid, $server_type); exit; } die "Unknown mode '$mode_type'. Cannot proceed.\n"; sub set_containers { my ($uid) = @_; defined $uid or die "Uid not defined in set_servers sub"; # Set server IDs my %server_no_for = ( web => $WEB_SERVER_ID, app => $APP_SERVER_ID, dev => $DEV_SERVER_ID, ); # Assing servers to user foreach my $server_type (keys %server_no_for) { # Get server number my $server_no = $server_no_for{$server_type}; # Add server to database $db_adduser{add_container}->execute( $uid, $server_type, $server_no ); } return; } sub satan { local @ARGV; # Satan arguments push @ARGV, '-a', $SATAN_ADDR if defined $SATAN_ADDR; push @ARGV, '-p', $SATAN_PORT if defined $SATAN_PORT; push @ARGV, '-k', $SATAN_KEY if defined $SATAN_KEY; push @ARGV, @_; # Send to satan my $response = do $SATAN_BIN; # Catch satan error if ($@) { my $error_message = $@; die "Cannot proccess $@"; } return $response; } sub do_rollback { my ($error_message, $user_id) = @_; $db_signup{set_status}->execute($error_message, $user_id); } exit;
var assert = require("assert"); var types = require("ast-types"); var n = types.namedTypes; var b = types.builders; var inherits = require("util").inherits; function Entry() { assert.ok(this instanceof Entry); } function FunctionEntry(returnLoc) { Entry.call(this); n.Literal.assert(returnLoc); Object.defineProperties(this, { returnLoc: { value: returnLoc } }); } inherits(FunctionEntry, Entry); exports.FunctionEntry = FunctionEntry; function LoopEntry(breakLoc, continueLoc, label) { Entry.call(this); n.Literal.assert(breakLoc); n.Literal.assert(continueLoc); if (label) { n.Identifier.assert(label); } else { label = null; } Object.defineProperties(this, { breakLoc: { value: breakLoc }, continueLoc: { value: continueLoc }, label: { value: label } }); } inherits(LoopEntry, Entry); exports.LoopEntry = LoopEntry; function SwitchEntry(breakLoc) { Entry.call(this); n.Literal.assert(breakLoc); Object.defineProperties(this, { breakLoc: { value: breakLoc } }); } inherits(SwitchEntry, Entry); exports.SwitchEntry = SwitchEntry; function TryEntry(catchEntry, finallyEntry) { Entry.call(this); if (catchEntry) { assert.ok(catchEntry instanceof CatchEntry); } else { catchEntry = null; } if (finallyEntry) { assert.ok(finallyEntry instanceof FinallyEntry); } else { finallyEntry = null; } Object.defineProperties(this, { catchEntry: { value: catchEntry }, finallyEntry: { value: finallyEntry } }); } inherits(TryEntry, Entry); exports.TryEntry = TryEntry; function CatchEntry(firstLoc, paramId) { Entry.call(this); n.Literal.assert(firstLoc); n.Identifier.assert(paramId); Object.defineProperties(this, { firstLoc: { value: firstLoc }, paramId: { value: paramId } }); } inherits(CatchEntry, Entry); exports.CatchEntry = CatchEntry; function FinallyEntry(firstLoc, nextLocTempVar) { Entry.call(this); n.Literal.assert(firstLoc); n.Identifier.assert(nextLocTempVar); Object.defineProperties(this, { firstLoc: { value: firstLoc }, nextLocTempVar: { value: nextLocTempVar } }); } inherits(FinallyEntry, Entry); exports.FinallyEntry = FinallyEntry; function LeapManager(emitter) { assert.ok(this instanceof LeapManager); var Emitter = require("./emit").Emitter; assert.ok(emitter instanceof Emitter); Object.defineProperties(this, { emitter: { value: emitter }, entryStack: { value: [new FunctionEntry(emitter.finalLoc)] } }); } var LMp = LeapManager.prototype; exports.LeapManager = LeapManager; LMp.withEntry = function(entry, callback) { assert.ok(entry instanceof Entry); this.entryStack.push(entry); try { callback.call(this.emitter); } finally { var popped = this.entryStack.pop(); assert.strictEqual(popped, entry); } }; LMp._leapToEntry = function(predicate, defaultLoc) { var entry, loc; var finallyEntries = []; var skipNextTryEntry = null; for (var i = this.entryStack.length - 1; i >= 0; --i) { entry = this.entryStack[i]; if (entry instanceof CatchEntry || entry instanceof FinallyEntry) { // If we are inside of a catch or finally block, then we must // have exited the try block already, so we shouldn't consider // the next TryStatement as a handler for this throw. skipNextTryEntry = entry; } else if (entry instanceof TryEntry) { if (skipNextTryEntry) { // If an exception was thrown from inside a catch block and this // try statement has a finally block, make sure we execute that // finally block. if (skipNextTryEntry instanceof CatchEntry && entry.finallyEntry) { finallyEntries.push(entry.finallyEntry); } skipNextTryEntry = null; } else if ((loc = predicate.call(this, entry))) { break; } else if (entry.finallyEntry) { finallyEntries.push(entry.finallyEntry); } } else if ((loc = predicate.call(this, entry))) { break; } } if (loc) { // fall through } else if (defaultLoc) { loc = defaultLoc; } else { return null; } n.Literal.assert(loc); var finallyEntry; while ((finallyEntry = finallyEntries.pop())) { this.emitter.emitAssign(finallyEntry.nextLocTempVar, loc); loc = finallyEntry.firstLoc; } return loc; }; function getLeapLocation(entry, property, label) { var loc = entry[property]; if (loc) { if (label) { if (entry.label && entry.label.name === label.name) { return loc; } } else { return loc; } } return null; } LMp.emitBreak = function(label) { var loc = this._leapToEntry(function(entry) { return getLeapLocation(entry, "breakLoc", label); }); if (loc === null) { throw new Error("illegal break statement"); } this.emitter.<API key>(); this.emitter.jump(loc); }; LMp.emitContinue = function(label) { var loc = this._leapToEntry(function(entry) { return getLeapLocation(entry, "continueLoc", label); }); if (loc === null) { throw new Error("illegal continue statement"); } this.emitter.<API key>(); this.emitter.jump(loc); };
{ Copyright (c) 2014-2020, Clockwork Dev Studio All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. {-# LANGUAGE CPP #-} module Arguments where import Prelude hiding (catch) import LexerData import Common import Options import Data.Char import System.FilePath.Posix import System.Directory import System.IO import Control.Exception import System.Exit import Control.Monad.State import Control.Monad.Except import Control.Monad.Identity import Debug.Trace import qualified Data.Sequence as Seq data ConfigFile = ConfigFile { <API key> :: [ConfigFileVariable] } deriving (Show,Eq) data ConfigFileVariable = ConfigFileVariable { <API key> :: String, <API key> :: String } deriving (Show, Eq) loadConfigFile :: Handle -> ConfigFile -> IO ConfigFile loadConfigFile handle (ConfigFile variables) = do let endOfFile :: IOError -> IO String endOfFile e = do return "EOF" line <- catch (hGetLine handle) endOfFile if line == "EOF" then return (ConfigFile variables) else do let (variable,rest) = span (isAlpha) line if variable == [] || rest == [] || head rest /= '=' then loadConfigFile handle (ConfigFile variables) else do loadConfigFile handle (ConfigFile (variables ++ [(ConfigFileVariable variable (tail rest))])) <API key> :: Options -> [ConfigFileVariable] -> Options <API key> originalOptions (configFileVariable:rest) = case <API key> configFileVariable of "backend" -> <API key> (originalOptions {optionAssembler = <API key> configFileVariable}) rest <API key> originalOptions _ = originalOptions processArguments :: CodeTransformation () processArguments = do homeDirectory <- liftIO $ getHomeDirectory let <API key> :: IOError -> IO Handle <API key> _ = do newConfHandle <- openFile (homeDirectory ++ "/.idlewild-lang.conf") WriteMode hPutStrLn newConfHandle "backend=nasm" hClose newConfHandle newConfHandle <- openFile (homeDirectory ++ "/.idlewild-lang.conf") ReadMode return newConfHandle confHandle <- liftIO $ (catch (openFile (homeDirectory ++ "/.idlewild-lang.conf") ReadMode) <API key>) configFile <- liftIO $ loadConfigFile confHandle (ConfigFile []) let customisedOptions = <API key> defaultOptions (<API key> configFile) liftIO $ hClose confHandle arguments <- gets <API key> (options, nonOptions) <- liftIO $ processOptions customisedOptions arguments if optionShowVersion options == True then do liftIO $ putStrLn "Idlewild-Lang version 0.0.5." liftIO $ exitSuccess else return () if length nonOptions /= 1 then do liftIO $ putStrLn "Please specify one (and only one) source file name." liftIO $ exitSuccess else return () let sourceFileName = head nonOptions asmFileName = replaceExtension sourceFileName ".asm" #if LINUX==1 || MAC_OS==1 objectFileName = replaceExtension sourceFileName ".o" #elif WINDOWS==1 objectFileName = replaceExtension sourceFileName ".obj" #endif verbose = optionVerbose options fromHandle <- liftIO $ openFile sourceFileName ReadMode toHandle <- liftIO $ openFile asmFileName WriteMode code <- liftIO $ hGetContents fromHandle put LexState {lexStateID = LEX_PENDING, <API key> = 0, <API key> = [sourceFileName], <API key> = [], <API key> = emptyToken, <API key> = Seq.empty, lexStateTokens = Seq.singleton (createBOFToken sourceFileName), lexStateLineNumber = 1, lexStateLineOffset = 0, lexStateCharacters = code, <API key> = allCompoundTokens, lexStateConfig = Config {configInputFile = fromHandle, configOutputFile = toHandle, <API key> = sourceFileName, configAsmFileName = asmFileName, <API key> = objectFileName, configOptions = options}} verboseCommentary ("Program arguments okay...\n") verbose verboseCommentary ("Source file '" ++ sourceFileName ++ "'...\n") verbose
#ifndef <API key> #define <API key> #include <mutex> #include "aos/linux_code/ipc_lib/aos_sync.h" #include "aos/common/logging/logging.h" #include "aos/common/type_traits.h" #include "aos/common/macros.h" namespace aos { // A mutex with the same API and semantics as ::std::mutex, with the addition of // methods for checking if the previous owner died and a constexpr default // constructor. // Definitely safe to put in SHM. // This uses the pthread_mutex semantics for owner-died: once somebody dies with // the lock held, anybody else who takes it will see true for owner_died() until // one of them calls consistent(). It is an error to call unlock() when // owner_died() returns true. class stl_mutex { public: constexpr stl_mutex() : native_handle_() {} void lock() { const int ret = mutex_grab(&native_handle_); switch (ret) { case 0: break; case 1: owner_died_ = true; break; default: LOG(FATAL, "mutex_grab(%p) failed with %d\n", &native_handle_, ret); } } bool try_lock() { const int ret = mutex_trylock(&native_handle_); switch (ret) { case 0: return true; case 1: owner_died_ = true; return true; case 4: return false; default: LOG(FATAL, "mutex_trylock(%p) failed with %d\n", &native_handle_, ret); } } void unlock() { CHECK(!owner_died_); mutex_unlock(&native_handle_); } typedef aos_mutex *native_handle_type; native_handle_type native_handle() { return &native_handle_; } bool owner_died() const { return owner_died_; } void consistent() { owner_died_ = false; } private: aos_mutex native_handle_; bool owner_died_ = false; <API key>(stl_mutex); }; // A mutex with the same API and semantics as ::std::recursive_mutex, with the // addition of methods for checking if the previous owner died and a constexpr // default constructor. // Definitely safe to put in SHM. // This uses the pthread_mutex semantics for owner-died: once somebody dies with // the lock held, anybody else who takes it will see true for owner_died() until // one of them calls consistent(). It is an error to call unlock() or lock() // again when owner_died() returns true. class stl_recursive_mutex { public: constexpr stl_recursive_mutex() {} void lock() { if (mutex_islocked(mutex_.native_handle())) { CHECK(!owner_died()); ++recursive_locks_; } else { mutex_.lock(); if (mutex_.owner_died()) { recursive_locks_ = 0; } else { CHECK_EQ(0, recursive_locks_); } } } bool try_lock() { if (mutex_islocked(mutex_.native_handle())) { CHECK(!owner_died()); ++recursive_locks_; return true; } else { if (mutex_.try_lock()) { if (mutex_.owner_died()) { recursive_locks_ = 0; } else { CHECK_EQ(0, recursive_locks_); } return true; } else { return false; } } } void unlock() { if (recursive_locks_ == 0) { mutex_.unlock(); } else { --recursive_locks_; } } typedef stl_mutex::native_handle_type native_handle_type; native_handle_type native_handle() { return mutex_.native_handle(); } bool owner_died() const { return mutex_.owner_died(); } void consistent() { mutex_.consistent(); } private: stl_mutex mutex_; int recursive_locks_ = 0; <API key>(stl_recursive_mutex); }; // Convenient typedefs for various types of locking objects. typedef ::std::lock_guard<stl_mutex> mutex_lock_guard; typedef ::std::lock_guard<stl_recursive_mutex> <API key>; typedef ::std::unique_lock<stl_mutex> mutex_unique_lock; typedef ::std::unique_lock<stl_recursive_mutex> <API key>; } // namespace aos #endif // <API key>
#pragma once namespace ASL { struct Expr { public: constructor Expr(); destructor virtual ~Expr(); private: }; } // namespace ASL
{% extends "fieldsight/fieldsight_base.html" %} {% load i18n staticfiles %} {% load filters %} {% block content %} <div id="main-content" class="padding"> {% if messages %} {% for message in messages %} <div class="alert alert-{% if message.tags %}{{ message.tags }}{% else %}info{% endif %}"> <strong class="text-capitalize">{% if message.tags %}{{ message.tags }}{% else %}info{% endif %}!</strong> {{ message }} </div> {% endfor %} {% endif %} {% if obj.children.all %} <section class="panel"> <header class="panel-heading clearfix"> <h3>{% trans 'Sub regions' %}</h3> </header> <div class="panel-body"> <div class="row"> {% for child in obj.children.all %} <div class="col-md-4 col-sm-6"> <a class="site-item-wrap margin-top" href="{% url 'fieldsight:regional-sites' child.project.pk child.pk %}"> <div class="basic-info clearfix"> <h4 class="detail-text1">{{ child.name }}</h4> <h6 class="detail-text0">{{ child.identifier }}</h6> <div>Total sites: {{ child.get_sites_count }}</div> </div> </a> </div> {% endfor %} </div> </div> </section> {% endif %} <section class="panel"> <header class="panel-heading clearfix"> <h3><i class="la la-map-marker"></i>{% if request.GET.q %}{% trans 'Search' %} {% trans 'result' %} {% trans 'for' %} "{{request.GET.q}}"{% else %}{% trans 'Sites' %}{% endif %}</h3> <div class="panel-heading-right"> <! <option class="dropdown-list" value="sitename" disabled selected>{% trans 'Sort' %} {% trans 'By' %}</option> <option value="progress">{% trans 'Site Progress' %}</option> <option value="identifier">{% trans 'Site Identifier' %}</option> <option value="sitename">{% trans 'Site Name' %}</option> <option value="pending">{% trans 'Number of Pending Submissions' %}</option> <option value="approved">{% trans 'Number of Approved Submissions' %}</option> <option value="flagged">{% trans 'Number of Flagged Submissions' %}</option> <option value="rejected">{% trans 'Number of Rejected Submissions' %}</option> </select> <a class="btn btn-sm btn-primary" data-toggle="collapse" href="#searchSite" aria-expanded="false" aria-controls="searchSite"><i class="la la-search"></i> {% trans 'Search' %}</a> {% if type == "project" %} <a href="{% url 'fieldsight:site-add' pk %}" title="" class="btn btn-sm btn-primary"><i class="la la-plus"></i> {% trans 'Add' %} {% trans 'New' %}</a> <a href="{% url 'fieldsight:define-site-meta' pk %}" title="" class="btn btn-sm btn-primary"><i class="la la-cogs"></i> {% trans 'Meta' %} {% trans 'Attributes' %}</a> <a href="{% url 'fieldsight:site-upload' pk %}" title="" class="btn btn-sm btn-primary"><i class="la la-files-o"></i> {% trans 'Bulk' %} {% trans 'Upload' %} {% trans 'Sites' %}</a> <a href="{% url 'fieldsight:bulk-edit-site' pk %}" title="" class="btn btn-sm btn-primary"><i class="la la-files-o"></i> {% trans 'Bulk' %} {% trans 'edit' %} {% trans 'Sites' %}</a> {% verbatim %} <div id="export_button"></div> {% endverbatim %} <script> configure_settings = {}; configure_settings.<API key> = false; configure_settings.url = "{% url 'fieldsight_export:<API key>' pk %}"; </script> <!-- <a href="{% url 'fieldsight_export:<API key>' pk %}" title="" class="btn btn-sm btn-primary"><i class="la la-plus"></i> {% trans 'Export' %} {% trans 'Sites' %} {% trans 'data' %} </a> {% endif %} {% if type == "region" %} <a href="{% url 'fieldsight:regional-site-add' pk region_id %}" title="" class="btn btn-sm btn-primary"><i class="la la-plus"></i> {% trans 'Add' %} {% trans 'New' %} {% trans 'Regional' %} {% trans 'Site' %}</a> <a href="{% url 'fieldsight:define-site-meta' pk %}" title="" class="btn btn-sm btn-primary"><i class="la la-cogs"></i> {% trans 'Meta' %} {% trans 'Attributes' %}</a> {% verbatim %} <div id="export_button"></div> {% endverbatim %} <script> configure_settings = {}; configure_settings.<API key> = false; configure_settings.url = "{% url 'fieldsight_export:<API key>' pk region_id %}"; </script> <!-- <a href="{% url 'fieldsight_export:<API key>' pk region_id %}" title="" class="btn btn-sm btn-primary"><i class="la la-plus"></i> {% trans 'Export' %} {% trans 'Sites' %} {% trans 'data' %} </a> {% elif type == "Unregioned" %} <a href="{% url 'fieldsight:site-add' project_id %}" title="" class="btn btn-sm btn-primary"><i class="la la-plus"></i> {% trans 'Add' %} {% trans 'New' %} {% trans 'Regional' %} {% trans 'Site' %}</a> <a href="{% url 'fieldsight:define-site-meta' project_id %}" title="" class="btn btn-sm btn-primary"><i class="la la-files-o"></i> {% trans 'Meta' %} {% trans 'Attributes' %}</a> {% verbatim %} <div id="export_button"></div> {% endverbatim %} <script> configure_settings = {}; configure_settings.<API key> = false; configure_settings.url = "{% url 'fieldsight_export:<API key>' project_id 0 %}"; </script> <!-- <a href="{% url 'fieldsight_export:<API key>' project_id %}" title="" class="btn btn-sm btn-primary"><i class="la la-plus"></i> {% trans 'Export' %} {% trans 'Sites' %} {% trans 'data' %} </a> {% endif %} </div> </header> <div class="panel-body"> <!--Search Organization <div class="collapse margin-top" id="searchSite"> <form class="padding" action="{% if region_id %}{% url 'fieldsight:<API key>' pk region_id %}{% else %}{% url 'fieldsight:search-site-list' pk %}{% endif %}" method="GET"> <div class="row"> <div class="col-md-6 ml-md-auto"> <div class="input-group"> <input type="text" class="form-control" name="q" placeholder="Search for..." required value='{{ request.GET.q }}'/> <span class="input-group-btn"> <button class="btn btn-primary" type="submit"><i class="la la-search"></i> {% trans 'Search' %}</button> </span> </div> </div> <div class="col-md-3"></div> </div> </form> </div> <div class="row" > {% for site in object_list %} <div class="col-md-4 col-sm-6"> <a href= {% url 'fieldsight:site-dashboard' site.pk %} title="" class="site-item-wrap margin-top clearfix"> <div class="logo"> <img src="{{ site.logo.url }}" alt="" width="100" height="100"> </div> <div class="basic-info clearfix"> <h4 class="detail-text1" >{{site.name}}</h4> <h6 class="detail-text0" >{{ site.identifier }}</h6> <p class="address"><i class="fa fa-map-marker" aria-hidden="true"></i> <span class="detail-text1">{{ site.address }}</span></p> <p class="phone"><i class="fa fa-phone" aria-hidden="true"></i> <span class="detail-text1">{{ site.phone }}</span></p> </div> {% with site.<API key> as count %} <ul class="icon-listing clearfix margin-top"> <li> <i class="la la-thumbs-up"></i> <span>{{ count.approved }} </span> </li> <li> <i class="la la-flag"></i> <span> {{ count.flagged }} </span> </li> <li> <i class="la la-hourglass-half"></i> <span> {{ count.outstanding }} </span> </li> <li> <i class="la la-exclamation"></i> <span> {{ count.rejected }} </span> </li> </ul> {% endwith %} <div class="progress margin-top"> <div class="progress progress-striped active progress-sm" style="width:100%;"> <div class="progress-bar <API key>" role="progressbar" style="width:{{ site.site_progress }}%;}"> <span class="progress-bar-value" style="color:grey;">{{ site.site_progress }}% Complete'"</span> </div> </div> </div> </a> </div> {% empty %} <div class="col-md-4 col-sm-6"> <h3>No Site</h3> </div> {% endfor %} </div> <br> {% if is_paginated %} <nav class="pagination <API key>" aria-label="page-navigation"> <ul class="pagination"> {% if page_obj.number == 1 %} {% else %} <li class="page-item"><a class="page-link" href="?page={{ 1 }}{% if request.GET.q %}&q={{request.GET.q}}{% endif %}">First</a></li> {% endif %} {% if page_obj.has_previous %} <li class="page-item"><a class="page-link" href="?page={{ page_obj.<API key> }}{% if request.GET.q %}&q={{request.GET.q}}{% endif %}">&laquo;</a></li> {% else %} <li class="page-item disabled"><a class="page-link" href="#">&laquo;</a></li> {% endif %} {% if paginator.num_pages > 21 %} {% page_offsets page_obj.number paginator.num_pages 20 as data %} {% for item in data.front_range %} <li class="page-item"><a class="page-link" href="?page={{ item }}{% if request.GET.q %}&q={{request.GET.q}}{% endif %}">{{ item }}</a></li> {% endfor %} <li class="page-item active"><a class="page-link" href="?page={{ page_obj.number }}{% if request.GET.q %}&q={{request.GET.q}}{% endif %}">{{ page_obj.number }}</a></li> {% for item in data.back_range %} <li class="page-item"><a class="page-link" href="?page={{ item }}{% if request.GET.q %}&q={{request.GET.q}}{% endif %}">{{ item }}</a></li> {% endfor %} {% else %} {% for i in paginator.page_range %} {% if page_obj.number == i %} <li class="page-item active"><a class="page-link" href="?page={{ i }}">{{ i }}</a></li> {% else %} <li class="page-item"><a class="page-link" href="?page={{ i }}">{{ i }}</a></li> {% endif %} {% endfor %} {% endif %} {% if page_obj.has_next %} <li class="page-item"><a class="page-link" href="?page={{ page_obj.next_page_number }}{% if request.GET.q %}&q={{request.GET.q}}{% endif %}">&raquo;</a></li> {% else %} <li class="page-item disabled"><a class="page-link" href="#">&raquo;</a></li> {% endif %} {% if page_obj.number == paginator.num_pages %} {% else %} <li class="page-item"><a class="page-link" href="?page={{ paginator.num_pages }}{% if request.GET.q %}&q={{request.GET.q}}{% endif %}">Last</a></li> {% endif %} </ul> </nav> {% endif %} </div> </section> </div> {% endblock %} {%block extrascript %} <script type="text/javascript" src="{% static 'vendor/vue.js' %}"></script> <script src="{% static 'js/forms/vue-resource.min.js' %}"></script> <script src="{% static 'js/fieldsight/site_export.js' %}?v=0.4"></script> {% endblock %}
#import<Foundation/Foundation.h> #import<Cocoa/Cocoa.h> extern NSMutableArray *search_results; @interface SearchController : NSObject<<API key>, NSTableViewDelegate> { } @end
class Gosec < Formula desc "Golang security checker" homepage "https://securego.io/" url "https://github.com/securego/gosec/archive/v2.7.0.tar.gz" sha256 "<SHA256-like>" license "Apache-2.0" head "https://github.com/securego/gosec.git" bottle do sha256 cellar: :any_skip_relocation, arm64_big_sur: "<SHA256-like>" sha256 cellar: :any_skip_relocation, big_sur: "<SHA256-like>" sha256 cellar: :any_skip_relocation, catalina: "<SHA256-like>" sha256 cellar: :any_skip_relocation, mojave: "<SHA256-like>" end depends_on "go" def install system "go", "build", *std_go_args, "-ldflags", "-X main.version=v#{version}", "./cmd/gosec" end test do (testpath/"test.go").write <<~EOS package main import "fmt" func main() { username := "admin" var <API key> fmt.Println("Doing something with: ", username, password) } EOS output = shell_output("#{bin}/gosec ./...", 1) assert_match "G101 (CWE-798)", output assert_match "Issues: 1", output end end
var http = require('http') var url = require('url') var path = require('path') var sleep = require('sleep-ref') var Router = require("routes-router") var concat = require('concat-stream') var ldj = require('ldjson-stream') var manifest = require('level-manifest') var multilevel = require('multilevel') var extend = require('extend') var prettyBytes = require('pretty-bytes') var jsonStream = require('JSONStream') var prebuiltEditor = require('dat-editor-prebuilt') var debug = require('debug')('rest-handler') var auth = require('./auth.js') var pump = require('pump') var zlib = require('zlib') var through = require('through2') module.exports = RestHandler function RestHandler(dat) { if (!(this instanceof RestHandler)) return new RestHandler(dat) this.dat = dat this.auth = auth(dat.options) this.router = this.createRoutes() this.sleep = sleep(function(opts) { opts.decode = true if (opts.live === 'true') opts.live = true if (opts.tail === 'true') opts.tail = true return dat.<API key>(opts) }, {style: 'newline'}) } RestHandler.prototype.createRoutes = function() { var router = Router() router.addRoute("/", this.dataTable.bind(this)) router.addRoute("/api/session", this.session.bind(this)) router.addRoute("/api/login", this.login.bind(this)) router.addRoute("/api/logout", this.logout.bind(this)) router.addRoute("/api/pull", this.pull.bind(this)) router.addRoute("/api/push", this.push.bind(this)) router.addRoute("/api/changes", this.changes.bind(this)) router.addRoute("/api/stats", this.stats.bind(this)) router.addRoute("/api/bulk", this.bulk.bind(this)) router.addRoute("/api/metadata", this.package.bind(this)) router.addRoute("/api/manifest", this.manifest.bind(this)) router.addRoute("/api/rpc", this.rpc.bind(this)) router.addRoute("/api/csv", this.exportCsv.bind(this)) router.addRoute("/api", this.hello.bind(this)) router.addRoute("/api/rows", this.document.bind(this)) router.addRoute("/api/rows/:key", this.document.bind(this)) router.addRoute("/api/rows/:key/:filename", this.blob.bind(this)) router.addRoute("/api/blobs/:key", this.blobs.bind(this)) router.addRoute("*", this.notFound.bind(this)) return router } RestHandler.prototype.session = function(req, res) { var self = this this.auth.handle(req, res, function(err, session) { debug('session', [err, session]) var data = {} if (err) return self.auth.error(req, res) if (session) data.session = session else data.loggedOut = true self.json(res, data) }) } RestHandler.prototype.login = function(req, res) { var self = this this.auth.handle(req, res, function(err, session) { debug('login', [err, session]) if (err) { res.setHeader("WWW-Authenticate", "Basic realm=\"Secure Area\"") self.auth.error(req, res) return } self.json(res, {session: session}) }) } RestHandler.prototype.logout = function(req, res) { return this.auth.error(req, res) } RestHandler.prototype.blob = function(req, res, opts) { var self = this if (req.method === 'GET') { var key = opts.key var blob = self.dat.<API key>(opts.key, opts.filename, opts) blob.on('error', function(err) { return self.error(res, 404, {"error": "Not Found"}) }) pump(blob, res) return } if (req.method === "POST") { var reqUrl = url.parse(req.url, true) var qs = reqUrl.query var doc = { key: opts.key, version: qs.version } self.auth.handle(req, res, function(err) { if (err) return self.auth.error(req, res) var key = doc.key self.dat.get(key, { version: doc.version }, function(err, existing) { if (existing) { doc = existing } var ws = self.dat.<API key>(opts.filename, doc, function(err, updated) { if (err) return self.error(res, 500, err) self.json(res, updated) }) pump(req, ws) }) return }) return } self.error(res, 405, {error: 'method not supported'}) } RestHandler.prototype.blobs = function(req, res, opts) { var self = this if (req.method === 'HEAD') { var key = opts.key var blob = self.dat.blobs.backend.exists(opts, function(err, exists) { res.statusCode = exists ? 200 : 404 res.setHeader('content-length', 0) res.end() }) return } if (req.method === 'GET') { res.statusCode = 200 return pump(self.dat.blobs.backend.createReadStream(opts), res) } self.error(res, 405, {error: 'method not supported'}) } var unzip = function(req) { return req.headers['content-encoding'] === 'gzip' ? zlib.createGunzip() : through() } var zip = function(req, res) { if (!/gzip/.test(req.headers['accept-encoding'] || '')) return through() res.setHeader('Content-Encoding', 'gzip') return zlib.createGzip() } RestHandler.prototype.push = function(req, res) { var self = this this.auth.handle(req, res, function(err) { if (err) return self.auth.error(req, res) pump(req, unzip(req), self.dat.replicator.receive(), function(err) { if (err) { res.statusCode = err.status || 500 res.end(err.message) return } res.end() }) }) } RestHandler.prototype.pull = function(req, res) { var reqUrl = url.parse(req.url, true) var qs = reqUrl.query var send = this.dat.replicator.send({ since: parseInt(qs.since, 10) || 0, blobs: qs.blobs !== 'false', live: !!qs.live }) pump(send, zip(req, res), res) } RestHandler.prototype.changes = function(req, res) { this.sleep.httpHandler(req, res) } RestHandler.prototype.stats = function(req, res) { var statsStream = this.dat.createStatsStream() statsStream.on('error', function(err) { var errObj = { type: 'statsStreamError', message: err.message } res.statusCode = 400 serializer.write(errObj) serializer.end() }) var serializer = ldj.serialize() pump(statsStream, serializer, res) } RestHandler.prototype.package = function(req, res) { var meta = {changes: this.dat.storage.change, liveBackup: this.dat.supportsLiveBackup()} meta.columns = this.dat.schema.headers() this.json(res, meta) } RestHandler.prototype.manifest = function(req, res) { this.json(res, manifest(this.dat.storage)) } RestHandler.prototype.rpc = function(req, res) { var self = this this.auth.handle(req, res, function(err) { if (err) return self.auth.error(req, res) var mserver = multilevel.server(self.dat.storage) pump(req, mserver, res) }) } RestHandler.prototype.exportCsv = function(req, res) { var reqUrl = url.parse(req.url, true) var qs = reqUrl.query qs.csv = true var readStream = this.dat.createReadStream(qs) res.writeHead(200, {'content-type': 'text/csv'}) pump(readStream, res) } RestHandler.prototype.exportJson = function(req, res) { var reqUrl = url.parse(req.url, true) var qs = reqUrl.query if (typeof qs.limit === 'undefined') qs.limit = 50 else qs.limit = +qs.limit var readStream = this.dat.createReadStream(qs) res.writeHead(200, {'content-type': 'application/json'}) pump(readStream, jsonStream.stringify('{"rows": [\n', '\n,\n', '\n]}\n'), res) } RestHandler.prototype.handle = function(req, res) { debug(req.connection.remoteAddress + ' - ' + req.method + ' - ' + req.url + ' - ') this.router(req, res) } RestHandler.prototype.error = function(res, status, message) { if (!status) status = res.statusCode if (message) { if (message.status) status = message.status if (typeof message === "object") message.status = status if (typeof message === "string") message = {error: status, message: message} } res.statusCode = status || 500 this.json(res, message) } RestHandler.prototype.notFound = function(req, res) { this.error(res, 404, {"error": "Not Found"}) } RestHandler.prototype.hello = function(req, res) { var self = this var stats = { "dat": "Hello", "version": this.dat.version, "changes": this.dat.storage.change, "name": this.dat.options.name } this.dat.storage.stat(function(err, stat) { if (err) return self.json(res, stats) stats.rows = stat.rows self.dat.storage.approximateSize(function(err, size) { if (err) return self.json(res, stats) stats.approximateSize = { rows: prettyBytes(size) } self.json(res, stats) }) }) } RestHandler.prototype.dataTable = function(req, res) { res.setHeader('content-type', 'text/html; charset=utf-8') res.end(prebuiltEditor) } RestHandler.prototype.json = function(res, json) { res.setHeader('content-type', 'application/json') res.end(JSON.stringify(json) + '\n') } RestHandler.prototype.get = function(req, res, opts) { var self = this this.dat.get(opts.key, url.parse(req.url, true).query || {}, function(err, json) { if (err && err.message === 'range not found') return self.error(res, 404, {error: "Not Found"}) if (err) return self.error(res, 500, err.message) if (json === null) return self.error(res, 404, {error: "Not Found"}) self.json(res, json) }) } RestHandler.prototype.post = function(req, res) { var self = this self.bufferJSON(req, function(err, json) { if (err) return self.error(res, 500, err) if (!json) json = {} self.dat.put(json, function(err, stored) { if (err) { if (err.conflict) return self.error(res, 409, {conflict: true, error: "Document update conflict. Invalid version"}) return self.error(res, 500, err) } res.statusCode = 201 self.json(res, stored) }) }) } RestHandler.prototype.delete = function(req, res, opts) { var self = this self.dat.delete(opts.key, function(err, stored) { if (err) return self.error(res, 500, err) self.json(res, {deleted: true}) }) } RestHandler.prototype.bulk = function(req, res) { var self = this var opts = {} var ct = req.headers['content-type'] if (ct === 'application/json') opts.json = true else if (ct === 'text/csv') opts.csv = true else return self.error(res, 400, {error: 'missing or unsupported content-type'}) opts.results = true debug('/api/bulk', opts) this.auth.handle(req, res, function(err) { if (err) return self.auth.error(req, res) var writeStream = self.dat.createWriteStream(opts) writeStream.on('error', function(writeErr) { var errObj = { type: 'writeStreamError', message: writeErr.message } res.statusCode = 400 serializer.write(errObj) serializer.end() }) var serializer = ldj.serialize() pump(req, writeStream, serializer, res) }) } RestHandler.prototype.document = function(req, res, opts) { var self = this if (req.method === "GET" || req.method === "HEAD") { if (opts.key) return this.get(req, res, opts) else return this.exportJson(req, res) } this.auth.handle(req, res, function(err) { if (err) return self.auth.error(req, res) if (req.method === "POST") return self.post(req, res, opts) if (req.method === "DELETE") return self.delete(req, res, opts) self.error(res, 405, {error: 'method not supported'}) }) } RestHandler.prototype.bufferJSON = function(req, cb) { var self = this req.on('error', function(err) { cb(err) }) req.pipe(concat(function(buff) { var json if (buff && buff.length === 0) return cb() if (buff) { try { json = JSON.parse(buff) } catch(err) { return cb(err) } } if (!json) return cb(err) cb(null, json) })) }
Ext.define('Sample.Application', { extend: 'Devon.App', name: 'Sample', requires:[ 'Sample.Simlets' ], controllers: [ 'Sample.controller.main.MainController', 'Sample.controller.table.TablesController', 'Sample.controller.cook.CookController' ], launch: function() { Devon.Log.trace('Sample.app launch'); console.log('Sample.app launch'); if (document.location.toString().indexOf('useSimlets')>=0){ Sample.Simlets.useSimlets(); } this.callParent(arguments); } });
package com.glob3mobile.vectorial.processing; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Comparator; import java.util.List; import com.glob3mobile.utils.Progress; import com.glob3mobile.vectorial.lod.<API key>; import com.glob3mobile.vectorial.lod.mapdb.<API key>; import com.glob3mobile.vectorial.storage.PointFeature; import com.glob3mobile.vectorial.storage.PointFeatureStorage; import com.glob3mobile.vectorial.storage.mapdb.<API key>; public class <API key> { private static class LeafNodesImporter implements PointFeatureStorage.NodeVisitor { private final long _nodesCount; private final <API key> _lodStorage; private final boolean _verbose; private Progress _progress; private LeafNodesImporter(final long nodesCount, final <API key> lodStorage, final boolean verbose) { _nodesCount = nodesCount; _lodStorage = lodStorage; _verbose = verbose; } @Override public void start() { _progress = new Progress(_nodesCount) { @Override public void informProgress(final long stepsDone, final double percent, final long elapsed, final long estimatedMsToFinish) { if (_verbose) { System.out.println(_lodStorage.getName() + ": 1/4 Importing leaf nodes: " + progressString(stepsDone, percent, elapsed, estimatedMsToFinish)); } } }; } @Override public void stop() { _progress.finish(); _progress = null; } @Override public boolean visit(final PointFeatureStorage.Node node) { final List<PointFeature> features = new ArrayList<>(node.getFeatures()); _lodStorage.addLeafNode( node.getID(), node.getNodeSector(), node.getMinimumSector(), features ); _progress.stepDone(); return true; } } public static void process(final File storageDir, final String storageName, final File lodDir, final String lodName, final int maxFeaturesPerNode, final Comparator<PointFeature> featuresComparator, final boolean createClusters, final boolean verbose) throws IOException { try (final PointFeatureStorage storage = <API key>.openReadOnly(storageDir, storageName)) { try (final <API key> lodStorage = <API key>.createEmpty(storage.getSector(), lodDir, lodName, maxFeaturesPerNode, featuresComparator, createClusters)) { final PointFeatureStorage.Statistics statistics = storage.getStatistics(verbose); if (verbose) { statistics.show(); System.out.println(); } final int nodesCount = statistics.getNodesCount(); storage.<API key>(new LeafNodesImporter(nodesCount, lodStorage, verbose)); lodStorage.createLOD(verbose); if (verbose) { System.out.println(lodStorage.getName() + ": 4/4 Optimizing storage..."); } lodStorage.optimize(); if (verbose) { System.out.println(); final <API key>.Statistics lodStatistics = lodStorage.getStatistics(verbose); lodStatistics.show(); } } } } private <API key>() { } public static void main(final String[] args) throws IOException { System.out.println("<API key> 0.1"); System.out.println(" final File sourceDir = new File("<API key>"); // final String sourceName = "Cities1000"; // final String sourceName = "AR"; // final String sourceName = "ES"; // final String sourceName = "<API key>"; // final String sourceName = "SpanishBars"; final String sourceName = "Tornados"; final File lodDir = new File("PointFeaturesLOD"); final String lodName = sourceName + "_LOD"; final int maxFeaturesPerNode = 64; // final int maxFeaturesPerNode = 96; final boolean createClusters = true; final Comparator<PointFeature> featuresComparator = createClusters ? null : new GEONamesComparator(); final boolean verbose = true; <API key>.process( sourceDir, sourceName, lodDir, lodName, maxFeaturesPerNode, featuresComparator, createClusters, verbose); System.out.println("\n- done!"); } }
const minDateStr = "-271821-04-20T00:00:00.000Z"; const minDate = new Date(-8640000000000000); assert.sameValue(minDate.toISOString(), minDateStr, "minDateStr"); assert.sameValue(Date.parse(minDateStr), minDate.valueOf(), "parse minDateStr"); const maxDateStr = "+275760-09-13T00:00:00.000Z"; const maxDate = new Date(8640000000000000); assert.sameValue(maxDate.toISOString(), maxDateStr, "maxDateStr"); assert.sameValue(Date.parse(maxDateStr), maxDate.valueOf(), "parse maxDateStr"); const belowRange = "-271821-04-19T23:59:59.999Z"; const aboveRange = "+275760-09-13T00:00:00.001Z"; assert.sameValue(Date.parse(belowRange), NaN, "parse below minimum time value"); assert.sameValue(Date.parse(aboveRange), NaN, "parse above maximum time value");
package ru.biocad.ig.alicont.conts.simple import ru.biocad.ig.alicont.algorithms.simple.SemiglobalAlignment import ru.biocad.ig.alicont.conts.SimpleAlicont class AlicontSemiglobal(maxheight : Int, query : String, gap : Double, score_matrix : Array[Array[Double]]) extends SimpleAlicont(maxheight : Int, query : String, gap : Double, score_matrix : Array[Array[Double]]) { def push(s : String) : Unit = { _strings.push(s) SemiglobalAlignment.extendMatrix(s, _query, _gap, _score, _matrix) } def alignment() : (Double, (String, String)) = { SemiglobalAlignment.traceback(target, _query, _gap, _score, _matrix) } }
#include <catch.hpp> #include <rapidcheck/catch.h> using namespace rc; TEST_CASE("scaleInteger") { prop("for uint32_t, equal to naive way", [] { const auto x = *gen::arbitrary<uint32_t>(); const auto size = *gen::nonNegative<int>(); RC_ASSERT(gen::detail::scaleInteger(x, size) == ((x * std::min<uint64_t>(kNominalSize, size) + (kNominalSize / 2)) / kNominalSize)); }); prop("result strictly increases with size", [](uint64_t x) { const auto sizeA = *gen::nonNegative<int>(); const auto sizeB = *gen::nonNegative<int>(); const auto small = std::min(sizeA, sizeB); const auto large = std::max(sizeA, sizeB); RC_ASSERT(gen::detail::scaleInteger(x, small) <= gen::detail::scaleInteger(x, large)); }); prop("result strictly increases with value", [](uint64_t a, uint64_t b){ const auto size = *gen::nonNegative<int>(); const auto small = std::min(a, b); const auto large = std::max(a, b); RC_ASSERT(gen::detail::scaleInteger(small, size) <= gen::detail::scaleInteger(large, size)); }); prop("yields input for kNominalSize", [](uint64_t x) { RC_ASSERT(gen::detail::scaleInteger(x, kNominalSize) == x); }); prop("yields 0 for 0", [](uint64_t x) { RC_ASSERT(gen::detail::scaleInteger(x, 0) == 0U); }); }
#ifndef EXTRACTION_WAY_HPP #define EXTRACTION_WAY_HPP #include "extractor/guidance/road_classification.hpp" #include "extractor/travel_mode.hpp" #include "util/guidance/turn_lanes.hpp" #include "util/typedefs.hpp" #include <string> #include <vector> namespace osrm { namespace extractor { namespace detail { inline void maybeSetString(std::string &str, const char *value) { if (value == nullptr) { str.clear(); } else { str = std::string(value); } } } /** * This struct is the direct result of the call to ```way_function``` * in the lua based profile. * * It is split into multiple edge segments in the ExtractorCallback. */ struct ExtractionWay { ExtractionWay() { clear(); } void clear() { forward_speed = -1; backward_speed = -1; forward_rate = -1; backward_rate = -1; duration = -1; weight = -1; name.clear(); ref.clear(); pronunciation.clear(); destinations.clear(); exits.clear(); turn_lanes_forward.clear(); turn_lanes_backward.clear(); road_classification = guidance::RoadClassification(); forward_travel_mode = <API key>; <API key> = <API key>; roundabout = false; circular = false; is_startpoint = true; forward_restricted = false; backward_restricted = false; <API key> = false; } // wrappers to allow assigning nil (nullptr) to string values void SetName(const char *value) { detail::maybeSetString(name, value); } const char *GetName() const { return name.c_str(); } void SetRef(const char *value) { detail::maybeSetString(ref, value); } const char *GetRef() const { return ref.c_str(); } void SetDestinations(const char *value) { detail::maybeSetString(destinations, value); } const char *GetDestinations() const { return destinations.c_str(); } void SetExits(const char *value) { detail::maybeSetString(exits, value); } const char *GetExits() const { return exits.c_str(); } void SetPronunciation(const char *value) { detail::maybeSetString(pronunciation, value); } const char *GetPronunciation() const { return pronunciation.c_str(); } void SetTurnLanesForward(const char *value) { detail::maybeSetString(turn_lanes_forward, value); } const char *GetTurnLanesForward() const { return turn_lanes_forward.c_str(); } void <API key>(const char *value) { detail::maybeSetString(turn_lanes_backward, value); } const char *<API key>() const { return turn_lanes_backward.c_str(); } // markers for determining user-defined classes for each way std::unordered_map<std::string, bool> forward_classes; std::unordered_map<std::string, bool> backward_classes; // speed in km/h double forward_speed; double backward_speed; // weight per meter double forward_rate; double backward_rate; // duration of the whole way in both directions double duration; // weight of the whole way in both directions double weight; std::string name; std::string ref; std::string pronunciation; std::string destinations; std::string exits; std::string turn_lanes_forward; std::string turn_lanes_backward; guidance::RoadClassification road_classification; TravelMode forward_travel_mode : 4; TravelMode <API key> : 4; // Boolean flags bool roundabout : 1; bool circular : 1; bool is_startpoint : 1; bool forward_restricted : 1; bool backward_restricted : 1; bool <API key> : 1; bool : 2; }; } } #endif // EXTRACTION_WAY_HPP
#include <math.h> #include "evas_common.h" #include "evas_blend_private.h" typedef struct _RGBA_Span RGBA_Span; typedef struct _RGBA_Edge RGBA_Edge; typedef struct _RGBA_Vertex RGBA_Vertex; struct _RGBA_Span { EINA_INLIST; int x, y, w; }; struct _RGBA_Edge { double x, dx; int i; }; struct _RGBA_Vertex { double x, y; int i; }; #define POLY_EDGE_DEL(_i) \ { \ int _j; \ \ for (_j = 0; (_j < num_active_edges) && (edges[_j].i != _i); _j++); \ if (_j < num_active_edges) \ { \ num_active_edges memmove(&(edges[_j]), &(edges[_j + 1]), \ (num_active_edges - _j) * sizeof(RGBA_Edge)); \ } \ } #define POLY_EDGE_ADD(_i, _y) \ { \ int _j; \ float _dx; \ RGBA_Vertex *_p, *_q; \ if (_i < (n - 1)) _j = _i + 1; \ else _j = 0; \ if (point[_i].y < point[_j].y) \ { \ _p = &(point[_i]); \ _q = &(point[_j]); \ } \ else \ { \ _p = &(point[_j]); \ _q = &(point[_i]); \ } \ edges[num_active_edges].dx = _dx = (_q->x - _p->x) / (_q->y - _p->y); \ edges[num_active_edges].x = (_dx * ((float)_y + 0.5 - _p->y)) + _p->x; \ edges[num_active_edges].i = _i; \ num_active_edges++; \ } EAPI void <API key>(void) { } EAPI RGBA_Polygon_Point * <API key>(RGBA_Polygon_Point *points, int x, int y) { RGBA_Polygon_Point *pt; pt = malloc(sizeof(RGBA_Polygon_Point)); if (!pt) return points; pt->x = x; pt->y = y; points = (RGBA_Polygon_Point *)eina_inlist_append(EINA_INLIST_GET(points), EINA_INLIST_GET(pt)); return points; } EAPI RGBA_Polygon_Point * <API key>(RGBA_Polygon_Point *points) { if (points) { while (points) { RGBA_Polygon_Point *old_p; old_p = points; points = (RGBA_Polygon_Point *)eina_inlist_remove(EINA_INLIST_GET(points), EINA_INLIST_GET(points)); free(old_p); } } return NULL; } static int <API key>(const void *a, const void *b) { RGBA_Vertex *p, *q; p = (RGBA_Vertex *)a; q = (RGBA_Vertex *)b; if (p->y <= q->y) return -1; return 1; } static int polygon_edge_sorter(const void *a, const void *b) { RGBA_Edge *p, *q; p = (RGBA_Edge *)a; q = (RGBA_Edge *)b; if (p->x <= q->x) return -1; return 1; } EAPI void <API key>(RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Polygon_Point *points, int x, int y) { RGBA_Gfx_Func func; RGBA_Polygon_Point *pt; RGBA_Vertex *point; RGBA_Edge *edges; Eina_Inlist *spans; int num_active_edges; int n; int i, j, k; int y0, y1, yi; int ext_x, ext_y, ext_w, ext_h; int *sorted_index; ext_x = 0; ext_y = 0; ext_w = dst->cache_entry.w; ext_h = dst->cache_entry.h; if (dc->clip.use) { if (dc->clip.x > ext_x) { ext_w += ext_x - dc->clip.x; ext_x = dc->clip.x; } if ((ext_x + ext_w) > (dc->clip.x + dc->clip.w)) { ext_w = (dc->clip.x + dc->clip.w) - ext_x; } if (dc->clip.y > ext_y) { ext_h += ext_y - dc->clip.y; ext_y = dc->clip.y; } if ((ext_y + ext_h) > (dc->clip.y + dc->clip.h)) { ext_h = (dc->clip.y + dc->clip.h) - ext_y; } } if ((ext_w <= 0) || (ext_h <= 0)) return; <API key>(); n = 0; EINA_INLIST_FOREACH(points, pt) n++; if (n < 3) return; edges = malloc(sizeof(RGBA_Edge) * n); if (!edges) return; point = malloc(sizeof(RGBA_Vertex) * n); if (!point) { free(edges); return; } sorted_index = malloc(sizeof(int) * n); if (!sorted_index) { free(edges); free(point); return; } k = 0; EINA_INLIST_FOREACH(points, pt) { point[k].x = pt->x + x; point[k].y = pt->y + y; point[k].i = k; k++; } qsort(point, n, sizeof(RGBA_Vertex), <API key>); for (k = 0; k < n; k++) sorted_index[k] = point[k].i; k = 0; EINA_INLIST_FOREACH(points, pt) { point[k].x = pt->x + x; point[k].y = pt->y + y; point[k].i = k; k++; } y0 = MAX(ext_y, ceil(point[sorted_index[0]].y - 0.5)); y1 = MIN(ext_y + ext_h - 1, floor(point[sorted_index[n - 1]].y - 0.5)); k = 0; num_active_edges = 0; spans = NULL; for (yi = y0; yi <= y1; yi++) { for (; (k < n) && (point[sorted_index[k]].y <= ((double)yi + 0.5)); k++) { i = sorted_index[k]; if (i > 0) j = i - 1; else j = n - 1; if (point[j].y <= ((double)yi - 0.5)) { POLY_EDGE_DEL(j) } else if (point[j].y > ((double)yi + 0.5)) { POLY_EDGE_ADD(j, yi) } if (i < (n - 1)) j = i + 1; else j = 0; if (point[j].y <= ((double)yi - 0.5)) { POLY_EDGE_DEL(i) } else if (point[j].y > ((double)yi + 0.5)) { POLY_EDGE_ADD(i, yi) } } qsort(edges, num_active_edges, sizeof(RGBA_Edge), polygon_edge_sorter); for (j = 0; j < num_active_edges; j += 2) { int x0, x1; x0 = ceil(edges[j].x - 0.5); if (j < (num_active_edges - 1)) x1 = floor(edges[j + 1].x - 0.5); else x1 = x0; if ((x1 >= ext_x) && (x0 < (ext_x + ext_w)) && (x0 <= x1)) { RGBA_Span *span; if (x0 < ext_x) x0 = ext_x; if (x1 >= (ext_x + ext_w)) x1 = ext_x + ext_w - 1; span = malloc(sizeof(RGBA_Span)); spans = eina_inlist_append(spans, EINA_INLIST_GET(span)); span->y = yi; span->x = x0; span->w = (x1 - x0) + 1; } edges[j].x += edges[j].dx; edges[j + 1].x += edges[j + 1].dx; } } free(edges); free(point); free(sorted_index); func = <API key>(dc->col.col, dst, 1, dc->render_op); if (spans) { RGBA_Span *span; EINA_INLIST_FOREACH(spans, span) { DATA32 *ptr; #ifdef EVAS_SLI if (((span->y) % dc->sli.h) == dc->sli.y) #endif { ptr = dst->image.data + (span->y * (dst->cache_entry.w)) + span->x; func(NULL, NULL, dc->col.col, ptr, span->w); } } while (spans) { span = (RGBA_Span *)spans; spans = eina_inlist_remove(spans, spans); free(span); } } }
#ifndef <API key> #define <API key> namespace APrinter { #define AMBRO_STRUCT_IF(name, condition) \ template <bool name##__IfEnable, typename name##__IfDummy = void> \ struct name##__impl {}; \ using name = name##__impl<(condition)>; \ template <typename name##__IfDummy> \ struct name##__impl <true, name##__IfDummy> #define AMBRO_STRUCT_ELSE(name) \ ; template <typename name##__IfDummy> \ struct name##__impl <false, name##__IfDummy> #define <API key>(name) \ template <bool name##__IfEnable, typename name##__IfDummy = void> \ struct name {}; \ template <typename name##__IfDummy> \ struct name <true, name##__IfDummy> } #endif
#include <ntddk.h> #include <xen.h> #include <util.h> #include "hypercall.h" #include "dbg_print.h" #include "assert.h" #define <API key> 2 #pragma code_seg("hypercall") __declspec(allocate("hypercall")) static UCHAR __Section[(<API key> + 1) * PAGE_SIZE]; static ULONG XenBaseLeaf = 0x40000000; static USHORT XenMajorVersion; static USHORT XenMinorVersion; static PFN_NUMBER HypercallPfn[<API key>]; static ULONG HypercallPfnCount; typedef UCHAR HYPERCALL_GATE[32]; typedef HYPERCALL_GATE *PHYPERCALL_GATE; PHYPERCALL_GATE Hypercall; NTSTATUS HypercallInitialize( VOID ) { ULONG EAX = 'DEAD'; ULONG EBX = 'DEAD'; ULONG ECX = 'DEAD'; ULONG EDX = 'DEAD'; ULONG Index; ULONG HypercallMsr; NTSTATUS status; status = STATUS_UNSUCCESSFUL; for (;;) { CHAR Signature[13] = {0}; __CpuId(XenBaseLeaf, &EAX, &EBX, &ECX, &EDX); *((PULONG)(Signature + 0)) = EBX; *((PULONG)(Signature + 4)) = ECX; *((PULONG)(Signature + 8)) = EDX; if (strcmp(Signature, "XenVMMXenVMM") == 0 && EAX >= XenBaseLeaf + 2) break; XenBaseLeaf += 0x100; if (XenBaseLeaf > 0x40000100) goto fail1; } __CpuId(XenBaseLeaf + 1, &EAX, NULL, NULL, NULL); XenMajorVersion = (USHORT)(EAX >> 16); XenMinorVersion = (USHORT)(EAX & 0xFFFF); Info("XEN %d.%d\n", XenMajorVersion, XenMinorVersion); Info("INTERFACE 0x%08x\n", <API key>); if ((ULONG_PTR)__Section & (PAGE_SIZE - 1)) Hypercall = (PVOID)(((ULONG_PTR)__Section + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)); else Hypercall = (PVOID)__Section; ASSERT3U(((ULONG_PTR)Hypercall & (PAGE_SIZE - 1)), ==, 0); for (Index = 0; Index < <API key>; Index++) { PHYSICAL_ADDRESS PhysicalAddress; PhysicalAddress = <API key>((PUCHAR)Hypercall + (Index << PAGE_SHIFT)); HypercallPfn[Index] = (PFN_NUMBER)(PhysicalAddress.QuadPart >> PAGE_SHIFT); } __CpuId(XenBaseLeaf + 2, &EAX, &EBX, NULL, NULL); HypercallPfnCount = EAX; ASSERT(HypercallPfnCount <= <API key>); HypercallMsr = EBX; for (Index = 0; Index < HypercallPfnCount; Index++) { Info("HypercallPfn[%d]: %p\n", Index, (PVOID)HypercallPfn[Index]); __writemsr(HypercallMsr, (ULONG64)HypercallPfn[Index] << PAGE_SHIFT); } return STATUS_SUCCESS; fail1: Error("fail1 (%08x)", status); return status; } extern uintptr_t __stdcall hypercall_gate_2(uint32_t ord, uintptr_t arg1, uintptr_t arg2); ULONG_PTR __Hypercall2( ULONG Ordinal, ULONG_PTR Argument1, ULONG_PTR Argument2 ) { return hypercall_gate_2(Ordinal, Argument1, Argument2); } extern uintptr_t __stdcall hypercall_gate_3(uint32_t ord, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3); ULONG_PTR __Hypercall3( ULONG Ordinal, ULONG_PTR Argument1, ULONG_PTR Argument2, ULONG_PTR Argument3 ) { return hypercall_gate_3(Ordinal, Argument1, Argument2, Argument3); } VOID HypercallTeardown( VOID ) { ULONG Index; Hypercall = NULL; for (Index = 0; Index < <API key>; Index++) HypercallPfn[Index] = 0; HypercallPfnCount = 0; }
# modification, are permitted provided that the following conditions are met: # and/or other materials provided with the distribution. # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import itertools import numba import numpy as np import os import pandas as pd import pyarrow.parquet as pq import random import string import unittest from numba import types import sdc from sdc import hiframes from sdc.str_arr_ext import StringArray from sdc.tests.test_base import TestCase from sdc.tests.test_utils import (count_array_OneDs, count_array_REPs, count_parfor_OneDs, count_parfor_REPs, dist_IR_contains, get_start_end, skip_numba_jit, skip_sdc_jit) class TestHiFrames(TestCase): @skip_numba_jit def <API key>(self): # make sure SDC copies the columns like Pandas does def test_impl(df): df2 = df[['A']] df2['A'] += 10 return df2.A, df.A hpat_func = self.jit(test_impl) n = 11 df = pd.DataFrame( {'A': np.arange(n), 'B': np.ones(n), 'C': np.random.ranf(n)}) np.testing.assert_array_equal(hpat_func(df.copy())[1], test_impl(df)[1]) @skip_numba_jit def <API key>(self): def test_impl(n): S1 = pd.Series(np.ones(n)) S2 = pd.Series(np.random.ranf(n)) df = pd.DataFrame({'A': S1, 'B': S2}) return df.A.sum() hpat_func = self.jit(test_impl) n = 11 self.assertEqual(hpat_func(n), test_impl(n)) self.assertEqual(count_array_REPs(), 0) self.assertEqual(count_parfor_REPs(), 0) self.assertEqual(count_parfor_OneDs(), 1) @skip_numba_jit def <API key>(self): def test_impl(df): return df['A'][df['B']].values hpat_func = self.jit(test_impl) df = pd.DataFrame({'A': [1, 2, 3], 'B': [True, False, True]}) np.testing.assert_array_equal(test_impl(df), hpat_func(df)) @skip_numba_jit def test_fillna(self): def test_impl(): A = np.array([1., 2., 3.]) A[0] = np.nan df = pd.DataFrame({'A': A}) B = df.A.fillna(5.0) return B.sum() hpat_func = self.jit(test_impl) self.assertEqual(hpat_func(), test_impl()) @skip_numba_jit def test_fillna_inplace(self): def test_impl(): A = np.array([1., 2., 3.]) A[0] = np.nan df = pd.DataFrame({'A': A}) df.A.fillna(5.0, inplace=True) return df.A.sum() hpat_func = self.jit(test_impl) self.assertEqual(hpat_func(), test_impl()) @skip_numba_jit def test_column_mean(self): def test_impl(): A = np.array([1., 2., 3.]) A[0] = np.nan df = pd.DataFrame({'A': A}) return df.A.mean() hpat_func = self.jit(test_impl) self.assertEqual(hpat_func(), test_impl()) @skip_numba_jit def test_column_var(self): def test_impl(): A = np.array([1., 2., 3.]) A[0] = 4.0 df = pd.DataFrame({'A': A}) return df.A.var() hpat_func = self.jit(test_impl) np.testing.assert_almost_equal(hpat_func(), test_impl()) @skip_numba_jit def test_column_std(self): def test_impl(): A = np.array([1., 2., 3.]) A[0] = 4.0 df = pd.DataFrame({'A': A}) return df.A.std() hpat_func = self.jit(test_impl) np.testing.assert_almost_equal(hpat_func(), test_impl()) @skip_numba_jit def test_column_map(self): def test_impl(n): df = pd.DataFrame({'A': np.arange(n)}) df['B'] = df.A.map(lambda a: 2 * a) return df.B.sum() n = 121 hpat_func = self.jit(test_impl) np.testing.assert_almost_equal(hpat_func(n), test_impl(n)) @skip_numba_jit def test_column_map_arg(self): def test_impl(df): df['B'] = df.A.map(lambda a: 2 * a) return n = 121 df1 = pd.DataFrame({'A': np.arange(n)}) df2 = pd.DataFrame({'A': np.arange(n)}) hpat_func = self.jit(test_impl) hpat_func(df1) self.assertTrue(hasattr(df1, 'B')) test_impl(df2) np.testing.assert_equal(df1.B.values, df2.B.values) @skip_numba_jit @skip_sdc_jit('Not implemented in sequential transport layer') def test_cumsum(self): def test_impl(n): df = pd.DataFrame({'A': np.ones(n), 'B': np.random.ranf(n)}) Ac = df.A.cumsum() return Ac.sum() hpat_func = self.jit(test_impl) n = 11 self.assertEqual(hpat_func(n), test_impl(n)) self.assertEqual(count_array_REPs(), 0) self.assertEqual(count_array_OneDs(), 2) self.assertEqual(count_parfor_REPs(), 0) self.assertEqual(count_parfor_OneDs(), 2) self.assertTrue(dist_IR_contains('dist_cumsum')) @skip_numba_jit @skip_sdc_jit('Not implemented in sequential transport layer') def <API key>(self): # make sure all column calls are distributed def test_impl(n): df = pd.DataFrame({'A': np.ones(n), 'B': np.random.ranf(n)}) df.A.fillna(5.0, inplace=True) DF = df.A.fillna(5.0) s = DF.sum() m = df.A.mean() v = df.A.var() t = df.A.std() Ac = df.A.cumsum() return Ac.sum() + s + m + v + t hpat_func = self.jit(test_impl) n = 11 self.assertEqual(hpat_func(n), test_impl(n)) self.assertEqual(count_array_REPs(), 0) self.assertEqual(count_parfor_REPs(), 0) self.assertTrue(dist_IR_contains('dist_cumsum')) @skip_numba_jit @skip_sdc_jit('Not implemented in sequential transport layer') def <API key>(self): def test_impl(n): df = pd.DataFrame({'A': np.arange(0, n, 1, np.float64)}) return df.A.quantile(.25) hpat_func = self.jit(test_impl) n = 1001 np.testing.assert_almost_equal(hpat_func(n), test_impl(n)) self.assertEqual(count_array_REPs(), 0) self.assertEqual(count_parfor_REPs(), 0) @unittest.skip('Error - fix needed\n' 'NUMA_PES=3 build') def <API key>(self): def test_impl(n): df = pd.DataFrame({'A': np.arange(0, n, 1, np.float32)}) df.A[0:100] = np.nan df.A[200:331] = np.nan return df.A.quantile(.25) hpat_func = self.jit(test_impl) n = 1001 np.testing.assert_almost_equal(hpat_func(n), test_impl(n)) self.assertEqual(count_array_REPs(), 0) self.assertEqual(count_parfor_REPs(), 0) @unittest.skip('Error - fix needed\n' 'NUMA_PES=3 build') def <API key>(self): def test_impl(n): df = pd.DataFrame({'A': np.arange(0, n, 1, np.int32)}) return df.A.quantile(.25) hpat_func = self.jit(test_impl) n = 1001 np.testing.assert_almost_equal(hpat_func(n), test_impl(n)) self.assertEqual(count_array_REPs(), 0) self.assertEqual(count_parfor_REPs(), 0) @unittest.skip('Error - fix needed\n' 'NUMA_PES=3 build') def <API key>(self): def test_impl(A): df = pd.DataFrame({'A': A}) return df.A.quantile(.25) hpat_func = self.jit(test_impl) n = 1001 A = np.arange(0, n, 1, np.float64) np.testing.assert_almost_equal(hpat_func(A), test_impl(A)) @skip_numba_jit def test_nunique(self): def test_impl(n): df = pd.DataFrame({'A': np.arange(n)}) df.A[2] = 0 return df.A.nunique() hpat_func = self.jit(test_impl) n = 1001 np.testing.assert_almost_equal(hpat_func(n), test_impl(n)) # test compile again for overload related issues hpat_func = self.jit(test_impl) np.testing.assert_almost_equal(hpat_func(n), test_impl(n)) @skip_numba_jit def <API key>(self): # TODO: test without file def test_impl(): df = pq.read_table('example.parquet').to_pandas() return df.four.nunique() hpat_func = self.jit(test_impl) self.assertEqual(hpat_func(), test_impl()) self.assertEqual(count_array_REPs(), 0) # test compile again for overload related issues hpat_func = self.jit(test_impl) self.assertEqual(hpat_func(), test_impl()) self.assertEqual(count_array_REPs(), 0) @skip_numba_jit def test_nunique_str(self): def test_impl(n): df = pd.DataFrame({'A': ['aa', 'bb', 'aa', 'cc', 'cc']}) return df.A.nunique() hpat_func = self.jit(test_impl) n = 1001 np.testing.assert_almost_equal(hpat_func(n), test_impl(n)) # test compile again for overload related issues hpat_func = self.jit(test_impl) np.testing.assert_almost_equal(hpat_func(n), test_impl(n)) @unittest.skip('AssertionError - fix needed\n' '5 != 3\n') def <API key>(self): # TODO: test without file def test_impl(): df = pq.read_table('example.parquet').to_pandas() return df.two.nunique() hpat_func = self.jit(test_impl) self.assertEqual(hpat_func(), test_impl()) self.assertEqual(count_array_REPs(), 0) # test compile again for overload related issues hpat_func = self.jit(test_impl) self.assertEqual(hpat_func(), test_impl()) self.assertEqual(count_array_REPs(), 0) @skip_numba_jit def <API key>(self): # TODO: test without file def test_impl(): df = pq.read_table('example.parquet').to_pandas() return (df.four.unique() == 3.0).sum() hpat_func = self.jit(test_impl) self.assertEqual(hpat_func(), test_impl()) self.assertEqual(count_array_REPs(), 0) @unittest.skip('AssertionError - fix needed\n' '2 != 1\n') def <API key>(self): # TODO: test without file def test_impl(): df = pq.read_table('example.parquet').to_pandas() return (df.two.unique() == 'foo').sum() hpat_func = self.jit(test_impl) self.assertEqual(hpat_func(), test_impl()) self.assertEqual(count_array_REPs(), 0) @skip_numba_jit @skip_sdc_jit('Not implemented in sequential transport layer') def test_describe(self): def test_impl(n): df = pd.DataFrame({'A': np.arange(0, n, 1, np.float64)}) return df.A.describe() hpat_func = self.jit(test_impl) n = 1001 hpat_func(n) # XXX: test actual output self.assertEqual(count_array_REPs(), 0) self.assertEqual(count_parfor_REPs(), 0) @skip_numba_jit def <API key>(self): def test_impl(): A = StringArray(['ABC', 'BB', 'ADEF']) df = pd.DataFrame({'A': A}) B = df.A.str.contains('AB*', regex=True) return B.sum() hpat_func = self.jit(test_impl) self.assertEqual(hpat_func(), 2) @skip_numba_jit def <API key>(self): def test_impl(): A = StringArray(['ABC', 'BB', 'ADEF']) df = pd.DataFrame({'A': A}) B = df.A.str.contains('BB', regex=False) return B.sum() hpat_func = self.jit(test_impl) self.assertEqual(hpat_func(), 1) @skip_numba_jit def <API key>(self): def test_impl(df): return df.A.str.replace('AB*', 'EE', regex=True) df = pd.DataFrame({'A': ['ABCC', 'CABBD']}) hpat_func = self.jit(test_impl) pd.testing.assert_series_equal( hpat_func(df), test_impl(df), check_names=False) @skip_numba_jit def <API key>(self): def test_impl(df): return df.A.str.replace('AB', 'EE', regex=False) df = pd.DataFrame({'A': ['ABCC', 'CABBD']}) hpat_func = self.jit(test_impl) pd.testing.assert_series_equal( hpat_func(df), test_impl(df), check_names=False) @skip_numba_jit def <API key>(self): def test_impl(df): B = df.A.str.replace('AB*', 'EE', regex=True) return B n = 5 A = ['ABCC', 'CABBD', 'CCD', 'CCDAABB', 'ED'] start, end = get_start_end(n) df = pd.DataFrame({'A': A[start:end]}) hpat_func = self.jit(distributed={'df', 'B'})(test_impl) pd.testing.assert_series_equal( hpat_func(df), test_impl(df), check_names=False) self.assertEqual(count_array_REPs(), 3) self.assertEqual(count_parfor_REPs(), 0) @skip_numba_jit def test_str_split(self): def test_impl(df): return df.A.str.split(',') df = pd.DataFrame({'A': ['AB,CC', 'C,ABB,D', 'G', '', 'g,f']}) hpat_func = self.jit(test_impl) pd.testing.assert_series_equal( hpat_func(df), test_impl(df), check_names=False) @skip_numba_jit def <API key>(self): def test_impl(df): return df.A.str.split() df = pd.DataFrame({'A': ['AB CC', 'C ABB D', 'G ', ' ', 'g\t f']}) hpat_func = self.jit(test_impl) pd.testing.assert_series_equal( hpat_func(df), test_impl(df), check_names=False) @skip_numba_jit def <API key>(self): def test_impl(df): B = df.A.str.split(',') df2 = pd.DataFrame({'B': B}) return df2[df2.B.str.len() > 1] df = pd.DataFrame({'A': ['AB,CC', 'C,ABB,D', 'G', '', 'g,f']}) hpat_func = self.jit(test_impl) pd.testing.assert_frame_equal( hpat_func(df), test_impl(df).reset_index(drop=True)) @skip_numba_jit def <API key>(self): def test_impl(df): return pd.DataFrame({'B': df.A.str.split(',')}) df = pd.DataFrame({'A': ['AB,CC', 'C,ABB,D']}) hpat_func = self.jit(test_impl) pd.testing.assert_series_equal( hpat_func(df).B, test_impl(df).B, check_names=False) @skip_numba_jit def <API key>(self): def test_impl(df): return df.A.iloc[0] df = pd.DataFrame({'A': ['AB,CC', 'C,ABB,D']}) df2 = pd.DataFrame({'A': df.A.str.split(',')}) hpat_func = self.jit(test_impl) self.assertEqual(hpat_func(df2), test_impl(df2)) @unittest.skip('Getitem Series with list values not implement') def <API key>(self): def test_impl(df): C = df.A.str.split(',') return C[df.B == 'aa'] df = pd.DataFrame({'A': ['AB,CC', 'C,ABB,D'], 'B': ['aa', 'bb']}) hpat_func = self.jit(test_impl) pd.testing.assert_series_equal( hpat_func(df), test_impl(df), check_names=False) @skip_numba_jit def <API key>(self): def test_impl(df): B = df.A.str.split(',') return B n = 5 start, end = get_start_end(n) A = ['AB,CC', 'C,ABB,D', 'CAD', 'CA,D', 'AA,,D'] df = pd.DataFrame({'A': A[start:end]}) hpat_func = self.jit(distributed={'df', 'B'})(test_impl) pd.testing.assert_series_equal( hpat_func(df), test_impl(df), check_names=False) self.assertEqual(count_array_REPs(), 3) self.assertEqual(count_parfor_REPs(), 0) @skip_numba_jit def test_str_get(self): def test_impl(df): B = df.A.str.split(',') return B.str.get(1) df = pd.DataFrame({'A': ['AB,CC', 'C,ABB,D']}) hpat_func = self.jit(test_impl) pd.testing.assert_series_equal( hpat_func(df), test_impl(df), check_names=False) @skip_numba_jit def test_str_split(self): def test_impl(df): return df.A.str.split(',') df = pd.DataFrame({'A': ['AB,CC', 'C,ABB,D']}) hpat_func = self.jit(test_impl) pd.testing.assert_series_equal(hpat_func(df), test_impl(df), check_names=False) @skip_numba_jit def <API key>(self): def test_impl(df): A = df.A.str.split(',') B = A.str.get(1) return B n = 5 start, end = get_start_end(n) A = ['AB,CC', 'C,ABB,D', 'CAD,F', 'CA,D', 'AA,,D'] df = pd.DataFrame({'A': A[start:end]}) hpat_func = self.jit(distributed={'df', 'B'})(test_impl) pd.testing.assert_series_equal( hpat_func(df), test_impl(df), check_names=False) self.assertEqual(count_array_REPs(), 3) self.assertEqual(count_parfor_REPs(), 0) @skip_numba_jit def <API key>(self): def test_impl(df): B = df.A.str.split(',') C = pd.to_numeric(B.str.get(1), errors='coerce') return C df = pd.DataFrame({'A': ['AB,12', 'C,321,D']}) hpat_func = self.jit(locals={'C': types.int64[:]})(test_impl) pd.testing.assert_series_equal( hpat_func(df), test_impl(df), check_names=False) @skip_numba_jit def test_str_flatten(self): def test_impl(df): A = df.A.str.split(',') return pd.Series(list(itertools.chain(*A))) df = pd.DataFrame({'A': ['AB,CC', 'C,ABB,D']}) hpat_func = self.jit(test_impl) pd.testing.assert_series_equal( hpat_func(df), test_impl(df), check_names=False) @skip_numba_jit def <API key>(self): def test_impl(df): A = df.A.str.split(',') B = pd.Series(list(itertools.chain(*A))) return B n = 5 start, end = get_start_end(n) A = ['AB,CC', 'C,ABB,D', 'CAD', 'CA,D', 'AA,,D'] df = pd.DataFrame({'A': A[start:end]}) hpat_func = self.jit(distributed={'df', 'B'})(test_impl) pd.testing.assert_series_equal( hpat_func(df), test_impl(df), check_names=False) self.assertEqual(count_array_REPs(), 3) self.assertEqual(count_parfor_REPs(), 0) @skip_numba_jit def test_to_numeric(self): def test_impl(df): B = pd.to_numeric(df.A, errors='coerce') return B df = pd.DataFrame({'A': ['123.1', '331.2']}) hpat_func = self.jit(locals={'B': types.float64[:]})(test_impl) pd.testing.assert_series_equal( hpat_func(df), test_impl(df), check_names=False) @skip_numba_jit def test_1D_Var_len(self): def test_impl(n): df = pd.DataFrame({'A': np.arange(n), 'B': np.arange(n) + 1.0}) df1 = df[df.A > 5] return len(df1.B) hpat_func = self.jit(test_impl) n = 11 self.assertEqual(hpat_func(n), test_impl(n)) self.assertEqual(count_array_REPs(), 0) self.assertEqual(count_parfor_REPs(), 0) @skip_numba_jit def test_rolling1(self): # size 3 without unroll def test_impl(n): df = pd.DataFrame({'A': np.arange(n), 'B': np.random.ranf(n)}) Ac = df.A.rolling(3).sum() return Ac.sum() hpat_func = self.jit(test_impl) n = 121 self.assertEqual(hpat_func(n), test_impl(n)) self.assertEqual(count_array_REPs(), 0) self.assertEqual(count_parfor_REPs(), 0) # size 7 with unroll def test_impl_2(n): df = pd.DataFrame({'A': np.arange(n) + 1.0, 'B': np.random.ranf(n)}) Ac = df.A.rolling(7).sum() return Ac.sum() hpat_func = self.jit(test_impl) n = 121 self.assertEqual(hpat_func(n), test_impl(n)) self.assertEqual(count_array_REPs(), 0) self.assertEqual(count_parfor_REPs(), 0) @skip_numba_jit def test_rolling2(self): def test_impl(n): df = pd.DataFrame({'A': np.ones(n), 'B': np.random.ranf(n)}) df['moving average'] = df.A.rolling(window=5, center=True).mean() return df['moving average'].sum() hpat_func = self.jit(test_impl) n = 121 self.assertEqual(hpat_func(n), test_impl(n)) self.assertEqual(count_array_REPs(), 0) self.assertEqual(count_parfor_REPs(), 0) @skip_numba_jit def test_rolling3(self): def test_impl(n): df = pd.DataFrame({'A': np.ones(n), 'B': np.random.ranf(n)}) Ac = df.A.rolling(3, center=True).apply(lambda a: a[0] + 2 * a[1] + a[2]) return Ac.sum() hpat_func = self.jit(test_impl) n = 121 self.assertEqual(hpat_func(n), test_impl(n)) self.assertEqual(count_array_REPs(), 0) self.assertEqual(count_parfor_REPs(), 0) @unittest.skip('Error - fix needed\n' 'NUMA_PES=3 build') def test_shift1(self): def test_impl(n): df = pd.DataFrame({'A': np.arange(n) + 1.0, 'B': np.random.ranf(n)}) Ac = df.A.shift(1) return Ac.sum() hpat_func = self.jit(test_impl) n = 11 self.assertEqual(hpat_func(n), test_impl(n)) self.assertEqual(count_array_REPs(), 0) self.assertEqual(count_parfor_REPs(), 0) @unittest.skip('Error - fix needed\n' 'NUMA_PES=3 build') def test_shift2(self): def test_impl(n): df = pd.DataFrame({'A': np.arange(n) + 1.0, 'B': np.random.ranf(n)}) Ac = df.A.pct_change(1) return Ac.sum() hpat_func = self.jit(test_impl) n = 11 np.testing.assert_almost_equal(hpat_func(n), test_impl(n)) self.assertEqual(count_array_REPs(), 0) self.assertEqual(count_parfor_REPs(), 0) @skip_numba_jit def test_df_input(self): def test_impl(df): return df.B.sum() n = 121 df = pd.DataFrame({'A': np.ones(n), 'B': np.random.ranf(n)}) hpat_func = self.jit(test_impl) np.testing.assert_almost_equal(hpat_func(df), test_impl(df)) @skip_numba_jit def test_df_input2(self): def test_impl(df): C = df.B == 'two' return C.sum() n = 11 df = pd.DataFrame({'A': np.random.ranf(3 * n), 'B': ['one', 'two', 'three'] * n}) hpat_func = self.jit(test_impl) np.testing.assert_almost_equal(hpat_func(df), test_impl(df)) @skip_numba_jit def test_df_input_dist1(self): def test_impl(df): return df.B.sum() n = 121 A = [3, 4, 5, 6, 1] B = [5, 6, 2, 1, 3] n = 5 start, end = get_start_end(n) df = pd.DataFrame({'A': A, 'B': B}) df_h = pd.DataFrame({'A': A[start:end], 'B': B[start:end]}) hpat_func = self.jit(distributed={'df'})(test_impl) np.testing.assert_almost_equal(hpat_func(df_h), test_impl(df)) self.assertEqual(count_array_REPs(), 0) self.assertEqual(count_parfor_REPs(), 0) @skip_numba_jit def test_concat(self): def test_impl(n): df1 = pd.DataFrame({'key1': np.arange(n), 'A': np.arange(n) + 1.0}) df2 = pd.DataFrame({'key2': n - np.arange(n), 'A': n + np.arange(n) + 1.0}) df3 = pd.concat([df1, df2]) return df3.A.sum() + df3.key2.sum() hpat_func = self.jit(test_impl) n = 11 self.assertEqual(hpat_func(n), test_impl(n)) self.assertEqual(count_array_REPs(), 0) self.assertEqual(count_parfor_REPs(), 0) n = 11111 self.assertEqual(hpat_func(n), test_impl(n)) @skip_numba_jit def test_concat_str(self): def test_impl(): df1 = pq.read_table('example.parquet').to_pandas() df2 = pq.read_table('example.parquet').to_pandas() A3 = pd.concat([df1, df2]) return (A3.two == 'foo').sum() hpat_func = self.jit(test_impl) self.assertEqual(hpat_func(), test_impl()) self.assertEqual(count_array_REPs(), 0) self.assertEqual(count_parfor_REPs(), 0) @skip_numba_jit def test_concat_series(self): def test_impl(n): df1 = pd.DataFrame({'key1': np.arange(n), 'A': np.arange(n) + 1.0}) df2 = pd.DataFrame({'key2': n - np.arange(n), 'A': n + np.arange(n) + 1.0}) A3 = pd.concat([df1.A, df2.A]) return A3.sum() hpat_func = self.jit(test_impl) n = 11 self.assertEqual(hpat_func(n), test_impl(n)) self.assertEqual(count_array_REPs(), 0) self.assertEqual(count_parfor_REPs(), 0) n = 11111 self.assertEqual(hpat_func(n), test_impl(n)) @skip_numba_jit def <API key>(self): def test_impl(): df1 = pq.read_table('example.parquet').to_pandas() df2 = pq.read_table('example.parquet').to_pandas() A3 = pd.concat([df1.two, df2.two]) return (A3 == 'foo').sum() hpat_func = self.jit(test_impl) self.assertEqual(hpat_func(), test_impl()) self.assertEqual(count_array_REPs(), 0) self.assertEqual(count_parfor_REPs(), 0) @skip_numba_jit @unittest.skipIf(int(os.getenv('SDC_NP_MPI', '0')) > 1, 'Test hangs on NP=2 and NP=3 on all platforms') def test_intraday(self): def test_impl(nsyms): max_num_days = 100 all_res = 0.0 for i in sdc.prange(nsyms): s_open = 20 * np.ones(max_num_days) s_low = 28 * np.ones(max_num_days) s_close = 19 * np.ones(max_num_days) df = pd.DataFrame({'Open': s_open, 'Low': s_low, 'Close': s_close}) df['Stdev'] = df['Close'].rolling(window=90).std() df['Moving Average'] = df['Close'].rolling(window=20).mean() df['Criteria1'] = (df['Open'] - df['Low'].shift(1)) < -df['Stdev'] df['Criteria2'] = df['Open'] > df['Moving Average'] df['BUY'] = df['Criteria1'] & df['Criteria2'] df['Pct Change'] = (df['Close'] - df['Open']) / df['Open'] df['Rets'] = df['Pct Change'][df['BUY']] all_res += df['Rets'].mean() return all_res hpat_func = self.jit(test_impl) n = 11 self.assertEqual(hpat_func(n), test_impl(n)) self.assertEqual(count_array_OneDs(), 0) self.assertEqual(count_parfor_OneDs(), 1) @skip_numba_jit def test_var_dist1(self): def test_impl(A, B): df = pd.DataFrame({'A': A, 'B': B}) df2 = df.groupby('A', as_index=False)['B'].sum() # TODO: fix handling of df setitem to force match of array dists # probably with a new node that is appended to the end of basic block # df2['C'] = np.full(len(df2.B), 3, np.int8) # TODO: full_like for Series df2['C'] = np.full_like(df2.B.values, 3, np.int8) return df2 A = np.array([1, 1, 2, 3]) B = np.array([3, 4, 5, 6]) hpat_func = self.jit(locals={'A:input': 'distributed', 'B:input': 'distributed', 'df2:return': 'distributed'})(test_impl) start, end = get_start_end(len(A)) df2 = hpat_func(A[start:end], B[start:end]) # TODO: # pd.testing.assert_frame_equal( # hpat_func(A[start:end], B[start:end]), test_impl(A, B)) if __name__ == "__main__": unittest.main()
@module fimbul.v35.material_template local material_template = {} function material_template:new(y) local neu = y or {} -- Do a deep resolve if neu.material then neu = neu.material end setmetatable(neu, self) self.__index = self neu.templatetype = "material" -- TODO: Check if everything is here and in proper order -- neu:check() return neu end return material_template
var crypto = require('crypto'); var Canvas = require('canvas'); var _ = require('lodash'); var bu = require('./bufutil'); var fmt = require('util').format; var unpack = require('./unpack'); var bright = require('./bright'); function fprint(buf, len) { if (len > 64) throw new Error(fmt("sha512 can only generate 64B of data: %dB requested", len)); return _(crypto.createHash('sha512').update(buf).digest()) .groupBy(function (x, k) { return Math.floor(k/len); }) .reduce(bu.xor); } function idhash(str, n, minFill, maxFill) { var buf = new Buffer(str.length + 1); buf.write(str); for (var i=0; i<0x100; i++) { buf[buf.length - 1] = i; var f = fprint(buf, Math.ceil(n/8)+6); var pixels = _(f.slice(6)) .map(function (x) { return unpack(x); }) .flatten().take(n); var setPixels = pixels.filter().size(); var c = [ f.slice(0, 3), f.slice(3, 6)]; c.sort(bright.cmp); if (setPixels > (minFill * n) && setPixels < (maxFill * n)) return { colors: c.map(function (x) { return x.toString('hex'); }), pixels: pixels.value() }; } throw new Error(fmt("String unhashable in single-byte search space.", str)); } function reflect(id, dimension) { var mid = Math.ceil(dimension / 2); var odd = Boolean(dimension % 2); var pic = []; for (var row=0; row<dimension; row++) { pic[row] = []; for (var col=0; col<dimension; col++) { var p = (row * mid) + col; if (col>=mid) { var d = mid - (odd ? 1 : 0) - col; var ad = Math.abs(d); p = (row * mid) + mid - 1 - ad; } pic[row][col] = id.pixels[p]; // console.error(fmt("looking for %d, of %d for %d,%d", p, id.pixels.length, row, col)) } } return pic; } function retricon(str, opts) { opts = _.merge({}, retricon.defaults, opts); var dimension = opts.tiles; var pixelSize = opts.pixelSize; var border = opts.pixelPadding; var mid = Math.ceil(dimension / 2); var id = idhash(str, mid * dimension, opts.minFill, opts.maxFill); var pic = reflect(id, dimension); var csize = (pixelSize * dimension) + (opts.imagePadding * 2); var c = Canvas.createCanvas(csize, csize); var ctx = c.getContext('2d'); if (_.isString(opts.bgColor)) { ctx.fillStyle = opts.bgColor; } else if (_.isNumber(opts.bgColor)) { ctx.fillStyle = '#' + id.colors[opts.bgColor]; } if (! _.isNull(opts.bgColor)) ctx.fillRect(0, 0, csize, csize); var drawOp = ctx.fillRect.bind(ctx); if (_.isString(opts.pixelColor)) { ctx.fillStyle = opts.pixelColor; } else if (_.isNumber(opts.pixelColor)) { ctx.fillStyle = '#' + id.colors[opts.pixelColor]; } else { drawOp = ctx.clearRect.bind(ctx); } for (var x=0; x<dimension; x++) for (var y=0; y<dimension; y++) if (pic[y][x]) drawOp((x*pixelSize) + border + opts.imagePadding, (y*pixelSize) + border + opts.imagePadding, pixelSize - (border * 2), pixelSize - (border * 2)); return c; } retricon.defaults = { pixelSize: 10, bgColor: null, pixelPadding: 0, imagePadding: 0, tiles: 5, minFill: 0.3, maxFill: 0.90, pixelColor: 0 }; retricon.style = { github: { pixelSize: 70, bgColor: '#F0F0F0', pixelPadding: -1, imagePadding: 35, tiles: 5 }, gravatar: { tiles: 8, bgColor: 1 }, mono: { bgColor: '#F0F0F0', pixelColor: '#000000', tiles: 6, pixelSize: 12, pixelPadding: -1, imagePadding: 6 }, mosaic: { imagePadding: 2, pixelPadding: 1, pixelSize: 16, bgColor: '#F0F0F0' }, mini: { pixelSize: 10, pixelPadding: 1, tiles: 3, bgColor: 0, pixelColor: 1 }, window: { pixelColor: null, bgColor: 0, imagePadding: 2, pixelPadding: 1, pixelSize: 16 } }; module.exports = retricon;
<?php namespace AppZap\PHPFramework\Tests\Functional\Testapp\Controller; use AppZap\PHPFramework\Mvc\AbstractController; class IndexController extends AbstractController { /** * @return string */ public function cli() { return ''; } }
#include <mscorlib/System/Runtime/Serialization/<API key>.h> #include <mscorlib/System/<API key>.h> #include <mscorlib/System/<API key>.h> namespace mscorlib { namespace System { namespace Runtime { namespace Serialization { //Public Methods void <API key>::RegisterObject(mscorlib::System::Object obj) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType(typeid(obj).name()); __parameters__[0] = (MonoObject*)obj; Global::InvokeMethod("mscorlib", "System.Runtime.Serialization", "<API key>", 0, NULL, "RegisterObject", __native_object__, 1, __parameter_types__, __parameters__, NULL); } void <API key>::<API key>() { Global::InvokeMethod("mscorlib", "System.Runtime.Serialization", "<API key>", 0, NULL, "<API key>", __native_object__, 0, NULL, NULL, NULL); } } } } }
#include "<API key>.h" #include <cds/intrusive/msqueue.h> #include <cds/gc/dhp.h> namespace queue { #define TEST(X) void <API key>::test_##X() { test<X>(); } namespace { typedef <API key>::base_hook_item< ci::msqueue::node<cds::gc::DHP > > base_item_type; typedef <API key>::member_hook_item< ci::msqueue::node<cds::gc::DHP > > member_item_type; // DHP base hook typedef ci::MSQueue< cds::gc::DHP, base_item_type, typename ci::msqueue::make_traits< ci::opt::hook< ci::msqueue::base_hook< ci::opt::gc<cds::gc::DHP> > > , ci::opt::disposer< <API key>::faked_disposer > >::type > MSQueue_DHP_base; // DHP member hook typedef ci::MSQueue< cds::gc::DHP, member_item_type, typename ci::msqueue::make_traits< ci::opt::hook< ci::msqueue::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<cds::gc::DHP> > > , ci::opt::disposer< <API key>::faked_disposer > >::type > MSQueue_DHP_member; DHP base hook + item counter typedef ci::MSQueue< cds::gc::DHP, base_item_type, typename ci::msqueue::make_traits< ci::opt::disposer< <API key>::faked_disposer > , ci::opt::hook< ci::msqueue::base_hook< ci::opt::gc<cds::gc::DHP> > > , co::item_counter< cds::atomicity::item_counter > , co::memory_model< co::v::relaxed_ordering > >::type > MSQueue_DHP_base_ic; // DHP member hook + item counter typedef ci::MSQueue< cds::gc::DHP, member_item_type, typename ci::msqueue::make_traits< ci::opt::hook< ci::msqueue::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<cds::gc::DHP> > > , ci::opt::disposer< <API key>::faked_disposer > , co::item_counter< cds::atomicity::item_counter > >::type > <API key>; // DHP base hook + stat typedef ci::MSQueue< cds::gc::DHP, base_item_type, typename ci::msqueue::make_traits< ci::opt::hook< ci::msqueue::base_hook< ci::opt::gc<cds::gc::DHP> > > , ci::opt::disposer< <API key>::faked_disposer > , co::stat< ci::msqueue::stat<> > >::type > <API key>; // DHP member hook + stat typedef ci::MSQueue< cds::gc::DHP, member_item_type, typename ci::msqueue::make_traits< ci::opt::hook< ci::msqueue::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<cds::gc::DHP> > > , ci::opt::disposer< <API key>::faked_disposer > , co::stat< ci::msqueue::stat<> > >::type > <API key>; // DHP base hook + alignment typedef ci::MSQueue< cds::gc::DHP, base_item_type, typename ci::msqueue::make_traits< ci::opt::disposer< <API key>::faked_disposer > , ci::opt::hook< ci::msqueue::base_hook< ci::opt::gc<cds::gc::DHP> > > , co::alignment< 32 > >::type > <API key>; // DHP member hook + alignment typedef ci::MSQueue< cds::gc::DHP, member_item_type, typename ci::msqueue::make_traits< ci::opt::hook< ci::msqueue::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc<cds::gc::DHP> > > , co::alignment< 32 > , ci::opt::disposer< <API key>::faked_disposer > >::type > <API key>; // DHP base hook + no alignment struct <API key> : public ci::msqueue::traits { typedef ci::msqueue::base_hook< ci::opt::gc<cds::gc::DHP> > hook; typedef <API key>::faked_disposer disposer; enum { alignment = co::<API key> }; }; typedef ci::MSQueue< cds::gc::DHP, base_item_type, <API key> > <API key>; // DHP member hook + no alignment struct <API key> : public ci::msqueue::traits { typedef ci::msqueue::member_hook < offsetof( member_item_type, hMember ), ci::opt::gc < cds::gc::DHP > > hook; typedef <API key>::faked_disposer disposer; enum { alignment = co::<API key> }; }; typedef ci::MSQueue< cds::gc::DHP, member_item_type, <API key> > <API key>; // DHP base hook + cache alignment struct <API key> : public <API key> { enum { alignment = co::<API key> }; }; typedef ci::MSQueue< cds::gc::DHP, base_item_type, <API key> > <API key>; // DHP member hook + cache alignment struct <API key> : public <API key> { enum { alignment = co::<API key> }; }; typedef ci::MSQueue< cds::gc::DHP, member_item_type, <API key> > <API key>; } // namespace TEST(MSQueue_DHP_base) TEST(MSQueue_DHP_member) TEST(MSQueue_DHP_base_ic) TEST(<API key>) TEST(<API key>) TEST(<API key>) TEST(<API key>) TEST(<API key>) TEST(<API key>) TEST(<API key>) TEST(<API key>) TEST(<API key>) } // namespace queue
var compilerSupport=require('../../src/compilerSupport');var main = function () { var __builder = new compilerSupport.TaskBuilder(), __state = 0, __continue = __builder.CONT, __ex; var data; return __builder.run(function () { switch (__state) { case 0: { data = 12345; console.log("data: " + data); __state = -1; __builder.ret(data); break; } default: throw 'Internal error: encountered wrong state'; } }); }; main().then(function(x) { console.log("returned: " + x); }, function(y) { console.log("failed: " + y); });
package test import ( "github.com/tidepool-org/platform/config" "github.com/tidepool-org/platform/log" "github.com/tidepool-org/platform/version" ) type Provider struct { <API key> int VersionReporterStub func() version.Reporter <API key> []version.Reporter <API key> *version.Reporter <API key> int ConfigReporterStub func() config.Reporter <API key> []config.Reporter <API key> *config.Reporter LoggerInvocations int LoggerStub func() log.Logger LoggerOutputs []log.Logger LoggerOutput *log.Logger PrefixInvocations int PrefixStub func() string PrefixOutputs []string PrefixOutput *string NameInvocations int NameStub func() string NameOutputs []string NameOutput *string <API key> int UserAgentStub func() string UserAgentOutputs []string UserAgentOutput *string } func NewProvider() *Provider { return &Provider{} } func (p *Provider) VersionReporter() version.Reporter { p.<API key>++ if p.VersionReporterStub != nil { return p.VersionReporterStub() } if len(p.<API key>) > 0 { output := p.<API key>[0] p.<API key> = p.<API key>[1:] return output } if p.<API key> != nil { return *p.<API key> } panic("VersionReporter has no output") } func (p *Provider) ConfigReporter() config.Reporter { p.<API key>++ if p.ConfigReporterStub != nil { return p.ConfigReporterStub() } if len(p.<API key>) > 0 { output := p.<API key>[0] p.<API key> = p.<API key>[1:] return output } if p.<API key> != nil { return *p.<API key> } panic("ConfigReporter has no output") } func (p *Provider) Logger() log.Logger { p.LoggerInvocations++ if p.LoggerStub != nil { return p.LoggerStub() } if len(p.LoggerOutputs) > 0 { output := p.LoggerOutputs[0] p.LoggerOutputs = p.LoggerOutputs[1:] return output } if p.LoggerOutput != nil { return *p.LoggerOutput } panic("Logger has no output") } func (p *Provider) Prefix() string { p.PrefixInvocations++ if p.PrefixStub != nil { return p.PrefixStub() } if len(p.PrefixOutputs) > 0 { output := p.PrefixOutputs[0] p.PrefixOutputs = p.PrefixOutputs[1:] return output } if p.PrefixOutput != nil { return *p.PrefixOutput } panic("Prefix has no output") } func (p *Provider) Name() string { p.NameInvocations++ if p.NameStub != nil { return p.NameStub() } if len(p.NameOutputs) > 0 { output := p.NameOutputs[0] p.NameOutputs = p.NameOutputs[1:] return output } if p.NameOutput != nil { return *p.NameOutput } panic("Name has no output") } func (p *Provider) UserAgent() string { p.<API key>++ if p.UserAgentStub != nil { return p.UserAgentStub() } if len(p.UserAgentOutputs) > 0 { output := p.UserAgentOutputs[0] p.UserAgentOutputs = p.UserAgentOutputs[1:] return output } if p.UserAgentOutput != nil { return *p.UserAgentOutput } panic("UserAgent has no output") } func (p *Provider) AssertOutputsEmpty() { if len(p.<API key>) > 0 { panic("<API key> is not empty") } if len(p.<API key>) > 0 { panic("<API key> is not empty") } if len(p.LoggerOutputs) > 0 { panic("LoggerOutputs is not empty") } if len(p.PrefixOutputs) > 0 { panic("PrefixOutputs is not empty") } if len(p.NameOutputs) > 0 { panic("NameOutputs is not empty") } if len(p.UserAgentOutputs) > 0 { panic("UserAgentOutputs is not empty") } }
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <sys/socket.h> #include <sys/types.h> #include <sys/epoll.h> #include <arpa/inet.h> #define BUFF_SIZE 1024 int main(int argc, const char *argv[]) { int i = 0; char buff[BUFF_SIZE]; ssize_t msg_len = 0; int srv_fd = -1; int cli_fd = -1; int epoll_fd = -1; struct sockaddr_in srv_addr; struct sockaddr_in cli_addr; socklen_t cli_addr_len; struct epoll_event e, es[2]; memset(&srv_addr, 0, sizeof(srv_addr)); memset(&cli_addr, 0, sizeof(cli_addr)); memset(&e, 0, sizeof(e)); srv_fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0); if (srv_fd < 0) { printf("Cannot create socket\n"); return 1; } srv_addr.sin_family = AF_INET; srv_addr.sin_addr.s_addr = htonl(INADDR_ANY); srv_addr.sin_port = htons(5555); if (bind(srv_fd, (struct sockaddr*) &srv_addr, sizeof(srv_addr)) < 0) { printf("Cannot bind socket\n"); close(srv_fd); return 1; } if (listen(srv_fd, 1) < 0) { printf("Cannot listen\n"); close(srv_fd); return 1; } epoll_fd = epoll_create(2); if (epoll_fd < 0) { printf("Cannot create epoll\n"); close(srv_fd); return 1; } e.events = EPOLLIN; e.data.fd = srv_fd; if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, srv_fd, &e) < 0) { printf("Cannot add server socket to epoll\n"); close(epoll_fd); close(srv_fd); return 1; } for(;;) { i = epoll_wait(epoll_fd, es, 2, -1); if (i < 0) { printf("Cannot wait for events\n"); close(epoll_fd); close(srv_fd); return 1; } for (--i; i > -1; --i) { if (es[i].data.fd == srv_fd) { cli_fd = accept(srv_fd, (struct sockaddr*) &cli_addr, &cli_addr_len); if (cli_fd < 0) { printf("Cannot accept client\n"); close(epoll_fd); close(srv_fd); return 1; } e.data.fd = cli_fd; if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, cli_fd, &e) < 0) { printf("Cannot accept client\n"); close(epoll_fd); close(srv_fd); return 1; } } if (es[i].data.fd == cli_fd) { if (es[i].events & EPOLLIN) { msg_len = read(cli_fd, buff, BUFF_SIZE); if (msg_len > 0) { write(cli_fd, buff, msg_len); } close(cli_fd); epoll_ctl(epoll_fd, EPOLL_CTL_DEL, cli_fd, &e); cli_fd = -1; } } } } return 0; }
/* * The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. * * Find the sum of all the primes below two million. */ #include <stdio.h> #include <stdint.h> #include "euler.h" #define PROBLEM 10 int main(int argc, char **argv) { uint64_t sum = 0, number = 0; do { number++; if(is_prime(number)) { sum += number; } } while(number != 2000000); printf("%llu\n", sum); return(0); }
using System; using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Text; namespace Mkko.Configuration { [<API key>(typeof(<API key>), AddItemName = "<API key>", CollectionType = <API key>.BasicMap)] public class <API key> : <API key> { public override <API key> CollectionType { get { return <API key>.BasicMap; } } protected override string ElementName { get { return "<API key>"; } } protected override <API key> CreateNewElement() { return new <API key>(); } protected override object GetElementKey(<API key> element) { return (element as <API key>).Id; } } }
import pytest import urllib.error from urlpathlib import UrlPath def test_scheme(): # does not raise NotImplementedError UrlPath('/dev/null').touch() def <API key>(): with pytest.raises(NotImplementedError): UrlPath('http:///tmp/test').touch() def <API key>(): with pytest.raises(NotImplementedError): UrlPath('test:///tmp/test').touch() def <API key>(): assert UrlPath('.').resolve() == UrlPath.cwd() def test_scheme_alias(): # does not raise NotImplementedError with pytest.raises(urllib.error.URLError): UrlPath('https://localhost/test').exists()
#endregion using System.Collections.Generic; namespace DexterCS { public class <API key> { public string ProjectName { get; set; } public string ProjectFullPath { get; set; } private List<string> sourceDirs; public List<string> SourceDirs { get { return sourceDirs ?? new List<string>(); } set { sourceDirs = value; } } private List<string> headerDirs; public List<string> HeaderDirs { get { return headerDirs ?? new List<string>(); } set { headerDirs = value; } } private List<string> targetDir; public List<string> TargetDirs { get { return targetDir ?? new List<string>(); } set { targetDir = value; } } public string Type { get; set; } } }
require "language/node" class HttpServer < Formula desc "Simple zero-configuration command-line HTTP server" homepage "https://github.com/http-party/http-server" url "https://registry.npmjs.org/http-server/-/http-server-13.0.1.tgz" sha256 "<SHA256-like>" license "MIT" head "https://github.com/http-party/http-server.git" bottle do sha256 cellar: :any_skip_relocation, all: "<SHA256-like>" end depends_on "node" def install system "npm", "install", *Language::Node.<API key>(libexec)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Ocronet.Dynamic.Recognizers; using Ocronet.Dynamic.OcroFST; using Ocronet.Dynamic; using Ocronet.Dynamic.ImgLib; using Ocronet.Dynamic.Interfaces; using Ocronet.Dynamic.Utils; using Ocronet.Dynamic.IOData; using System.IO; using Ocronet.Dynamic.Segmentation; using Ocronet.Dynamic.Recognizers.Lenet; namespace Ocronet.DynamicConsole { public class TestLinerec { public void TestSimple() { Global.SetEnv("debug", Global.GetEnv("debug") + ""); // image file name to recognize string imgFileName = "line.png"; string imgCsegFileName = "line.cseg.png"; string <API key> = "line.txt"; // line recognizer Linerec lrec = (Linerec)Linerec.LoadLinerec("default.model"); //Linerec lrec = (Linerec)Linerec.LoadLinerec("2m2-reject.cmodel"); //Linerec lrec = (Linerec)Linerec.LoadLinerec("multi3.cmodel"); //Linerec lrec = (Linerec)Linerec.LoadLinerec("latin-ascii.model"); lrec.Info(); // language model OcroFST default_lmodel = OcroFST.MakeOcroFst(); default_lmodel.Load("default.fst"); OcroFST lmodel = default_lmodel; // read image Bytearray image = new Bytearray(1, 1); ImgIo.read_image_gray(image, imgFileName); // recognize! OcroFST fst = OcroFST.MakeOcroFst(); Intarray rseg = new Intarray(); lrec.RecognizeLine(rseg, fst, image); // show result 1 string resStr; fst.BestPath(out resStr); Console.WriteLine("Fst BestPath: {0}", resStr); // find result 2 Intarray v1 = new Intarray(); Intarray v2 = new Intarray(); Intarray inp = new Intarray(); Intarray outp = new Intarray(); Floatarray c = new Floatarray(); BeamSearch.beam_search(v1, v2, inp, outp, c, fst, lmodel, 100); FstUtil.remove_epsilons(out resStr, outp); Console.WriteLine("Fst BeamSearch: {0}", resStr); Intarray cseg = new Intarray(); SegmRoutine.rseg_to_cseg(cseg, rseg, inp); SegmRoutine.<API key>(cseg); ImgLabels.simple_recolor(cseg); // for human readable ImgIo.write_image_packed(imgCsegFileName, cseg); File.WriteAllText(<API key>, resStr.Replace(" ", "")); } public void TestTrainLenetCseg() { string bookPath = "data\\0000\\"; string netFileName = "latin-lenet.model"; Linerec.GDef("linerec", "use_reject", 1); Linerec.GDef("lenet", "junk", 1); Linerec.GDef("lenet", "epochs", 4); // create Linerec Linerec linerec; if (File.Exists(netFileName)) linerec = Linerec.LoadLinerec(netFileName); else { linerec = new Linerec("lenet"); LenetClassifier classifier = linerec.GetClassifier() as LenetClassifier; if (classifier != null) classifier.<API key>(); } // temporary disable junk //linerec.DisableJunk = true; linerec.StartTraining(); int nepochs = 10; LineSource lines = new LineSource(); lines.Init(new string[] { "data2" }); //linerec.GetClassifier().Set("epochs", 1); for (int epoch = 1; epoch <= nepochs; epoch++) { linerec.Epoch(epoch); // load cseg samples while (!lines.Done()) { lines.MoveNext(); Intarray cseg = new Intarray(); //Bytearray image = new Bytearray(); string transcript = lines.GetTranscript(); //lines.GetImage(image); if (!lines.GetCharSegmentation(cseg) && cseg.Length() == 0) { Global.Debugf("warn", "skipping book {0} page {1} line {2} (no or bad cseg)", lines.CurrentBook, lines.CurrentPage, lines.Current); continue; } SegmRoutine.<API key>(cseg); linerec.AddTrainingLine(cseg, transcript); } lines.Reset(); lines.Shuffle(); // do Train and clear Dataset linerec.FinishTraining(); // do save if (epoch % 1 == 0) linerec.Save(netFileName); // recognize test line bool bakDisJunk = linerec.DisableJunk; linerec.DisableJunk = false; <API key>(linerec, "data2\\", "test1.png"); linerec.DisableJunk = bakDisJunk; } // finnaly save linerec.Save(netFileName); } public void TestTrainLatinCseg() { string bookPath = "data\\0000\\"; string netFileName = "latin-amlp.model"; Linerec.GDef("linerec", "use_reject", 1); Linerec.GDef("lenet", "junk", 1); // create Linerec Linerec linerec; if (File.Exists(netFileName)) linerec = Linerec.LoadLinerec(netFileName); else { linerec = new Linerec("latin"); } // temporary disable junk //linerec.DisableJunk = true; linerec.StartTraining(); int nepochs = 1; LineSource lines = new LineSource(); lines.Init(new string[] { "data2" }); for (int epoch = 1; epoch <= nepochs; epoch++) { linerec.Epoch(epoch); // load cseg samples while (lines.MoveNext()) { Intarray cseg = new Intarray(); //Bytearray image = new Bytearray(); string transcript = lines.GetTranscript(); //lines.GetImage(image); if (!lines.GetCharSegmentation(cseg) && cseg.Length() == 0) { Global.Debugf("warn", "skipping book {0} page {1} line {2} (no or bad cseg)", lines.CurrentBook, lines.CurrentPage, lines.CurrentLine); continue; } SegmRoutine.<API key>(cseg); linerec.AddTrainingLine(cseg, transcript); } lines.Reset(); lines.Shuffle(); // do Train and clear Dataset linerec.FinishTraining(); // do save if (epoch % 1 == 0) linerec.Save(netFileName); // recognize test line bool bakDisJunk = linerec.DisableJunk; linerec.DisableJunk = false; <API key>(linerec, bookPath, "000010.png"); linerec.DisableJunk = bakDisJunk; } // finnaly save linerec.Save(netFileName); } private void <API key>(Linerec linerec, string bookPath, string filename) { Bytearray image = new Bytearray(); ImgIo.read_image_gray(image, bookPath + filename); // recognize! OcroFST fst = OcroFST.MakeOcroFst(); linerec.RecognizeLine(fst, image); // show result string resStr; fst.BestPath(out resStr); Console.WriteLine("Fst BestPath: {0}", resStr); } public void TestRecognizeCseg() { string book1Path = "data2\\0001\\"; string book2Path = "data\\0000\\"; //Linerec.GDef("linerec", "use_reject", 0); //Linerec.GDef("lenet", "junk", 0); Linerec linerec = Linerec.LoadLinerec("latin-amlp.model"); //Linerec linerec = Linerec.LoadLinerec("latin-lenet.model"); //Linerec linerec = Linerec.LoadLinerec("latin-ascii2.model"); //Linerec linerec = Linerec.LoadLinerec("default.model"); //linerec.Set("maxcost", 20); <API key>(linerec, book1Path, "0010.png"); <API key>(linerec, book1Path, "0001.png"); <API key>(linerec, book1Path, "0089.png"); <API key>(linerec, book1Path, "0026.png"); <API key>(linerec, book2Path, "000001.png"); } public void <API key>() { //<API key>("data", "default.model", ""); //<API key>("data2", "latin-ascii.model", "gt"); <API key>("data", "latin-lenet.model", ""); } <summary> Create char segmentation (cseg) files if missing </summary> <param name="bookPath">path to bookstore</param> <param name="modelFilename">Linerec model file</param> <param name="langModel">language model file</param> <param name="suffix">e.g., 'gt'</param> public void <API key>(string bookPath, string model = "default.model", string suffix = "", bool saveRseg = false, string langModel = "default.fst") { // create line recognizer Linerec linerec = Linerec.LoadLinerec(model); // create IBookStore IBookStore bookstore = new SmartBookStore(); bookstore.SetPrefix(bookPath); bookstore.Info(); // language model OcroFST lmodel = OcroFST.MakeOcroFst(); lmodel.Load(langModel); // iterate lines of pages for (int page = 0; page < bookstore.NumberOfPages(); page++) { int nlines = bookstore.LinesOnPage(page); Console.WriteLine("Page {0} has {1} lines", page, nlines); for (int j = 0; j < nlines; j++) { int line = bookstore.GetLineId(page, j); Bytearray image = new Bytearray(); bookstore.GetLine(image, page, line); Intarray cseg = new Intarray(); bookstore.GetCharSegmentation(cseg, page, line, suffix); // check missing cseg file if (cseg.Length() <= 0 && image.Length() > 0) { // recognize line OcroFST fst = OcroFST.MakeOcroFst(); Intarray rseg = new Intarray(); linerec.RecognizeLine(rseg, fst, image); // find best results string resText; Intarray inp = new Intarray(); Floatarray costs = new Floatarray(); double totalCost = BeamSearch.beam_search(out resText, inp, costs, fst, lmodel, 100); Console.WriteLine(bookstore.PathFile(page, line, suffix)); Console.Write(" beam_search score: {0}", totalCost); /*string resText2; fst.BestPath(out resText2);*/ // write cseg to bookstore string trans; bookstore.GetLine(out trans, page, line, suffix); resText = resText.Replace(" ", ""); if (String.IsNullOrEmpty(trans)) { bookstore.PutLine(resText, page, line, suffix); Console.Write("; transcript saved"); } else if (trans == resText) { // convert inputs and rseg to cseg SegmRoutine.rseg_to_cseg(cseg, rseg, inp); bookstore.PutCharSegmentation(cseg, page, line, suffix); Console.Write("; cseg saved"); } else if (saveRseg) { // convert inputs and rseg to cseg SegmRoutine.rseg_to_cseg(cseg, rseg, inp); //SegmRoutine.<API key>(cseg, 4); /*bookstore.PutCharSegmentation(cseg, page, line, suffix); Console.Write("; cseg saved");*/ SegmRoutine.<API key>(cseg); ImgLabels.simple_recolor(cseg); string v = "rseg"; if (!String.IsNullOrEmpty(suffix)) { v += "."; v += suffix; } string rsegpath = bookstore.PathFile(page, line, v, "png"); ImgIo.write_image_packed(rsegpath, cseg); Console.Write("; rseg saved"); } Console.WriteLine(); } } } } } }
class Opusfile < Formula desc "API for decoding and seeking in .opus files" homepage "https: url "https://archive.mozilla.org/pub/opus/opusfile-0.11.tar.gz" sha256 "<SHA256-like>" revision 1 bottle do cellar :any rebuild 1 sha256 "<SHA256-like>" => :catalina sha256 "<SHA256-like>" => :mojave sha256 "<SHA256-like>" => :high_sierra end head do url "https://gitlab.xiph.org/xiph/opusfile.git" depends_on "autoconf" => :build depends_on "automake" => :build depends_on "libtool" => :build end depends_on "pkg-config" => :build depends_on "libogg" depends_on "openssl@1.1" depends_on "opus" resource "music_48kbps.opus" do url "https: sha256 "<SHA256-like>" end def install system "./autogen.sh" if build.head? system "./configure", "--<API key>", "--prefix=#{prefix}" system "make", "install" end test do testpath.install resource("music_48kbps.opus") (testpath/"test.c").write <<~EOS #include <opus/opusfile.h> #include <stdlib.h> int main(int argc, const char **argv) { int ret; OggOpusFile *of; of = op_open_file(argv[1], &ret); if (of == NULL) { fprintf(stderr, "Failed to open file '%s': %i\\n", argv[1], ret); return EXIT_FAILURE; } op_free(of); return EXIT_SUCCESS; } EOS system ENV.cc, "test.c", "-I#{Formula["opus"].include}/opus", "-L#{lib}", "-lopusfile", "-o", "test" system "./test", "music_48kbps.opus" end end
cask 'opera-beta' do version '50.0.2762.42' sha256 '<SHA256-like>' url "https://get.geo.opera.com/pub/opera-beta/#{version}/mac/Opera_beta_#{version}_Setup.dmg" name 'Opera Beta' homepage 'https: auto_updates true app 'Opera Beta.app' end
#ifndef IVW_GLFWEXCEPTION_H #define IVW_GLFWEXCEPTION_H #include <modules/glfw/glfwmoduledefine.h> #include <inviwo/core/common/inviwo.h> #include <inviwo/core/util/exception.h> namespace inviwo { /** * \class GLFWException */ class IVW_MODULE_GLFW_API GLFWException : public Exception { public: GLFWException(const std::string& message = "", ExceptionContext context = ExceptionContext()); virtual ~GLFWException() throw() {} }; class IVW_MODULE_GLFW_API GLFWInitException : public ModuleInitException { public: GLFWInitException(const std::string& message = "", ExceptionContext context = ExceptionContext()); virtual ~GLFWInitException() throw() {} }; } // namespace #endif // IVW_GLFWEXCEPTION_H
package com.xfsi.xav.validation.images.jpeg; import java.io.DataInputStream; import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.util.LinkedList; /** * Handles JPEG input stream. Tracks total bytes read and allows putting back of read data. */ class JpegInputStream { private int readByteCount = 0; private final DataInputStream inputStream; private LinkedList<Byte> putBack = new LinkedList<Byte>(); JpegInputStream(InputStream is) { this.inputStream = new DataInputStream(is); } byte readByte() throws EOFException, IOException { if (this.putBack.size() == 0) { byte b = this.inputStream.readByte(); this.readByteCount++; return b; } return this.putBack.remove(); } short readShort() throws EOFException, IOException { if (this.putBack.size() == 0) { short s = this.inputStream.readShort(); this.readByteCount += 2; return s; } short msb = readByte(); short lsb = readByte(); return (short) ((msb << 8) | (lsb & 0xff)); } int readInt() throws EOFException, IOException { if (this.putBack.size() == 0) { int i = this.inputStream.readInt(); this.readByteCount += 4; return i; } int mss = readShort(); int lss = readShort(); return (mss << 16) | (lss & 0xffff); } void skipBytes(int count) throws EOFException, IOException { // DataInputStream skipBytes() in jpegInputStream does not throw EOFException() if EOF reached, // which we are interested in, so read the bytes to skip them which WILL generate an EOFException(). for (int i = 0; i < count; i++) readByte(); } void putBack(byte b) { this.putBack.add(b); } int getTotalBytesRead() { return this.readByteCount; } }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http: <html xmlns="http: <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>CLI - bossing Varnish around &mdash; Varnish version 4.0.0 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var <API key> = { URL_ROOT: '../', VERSION: '4.0.0', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <link rel="top" title="Varnish version 4.0.0 documentation" href="../index.html" /> <link rel="up" title="Starting and running Varnish" href="running.html" /> <link rel="next" title="Storage backends" href="storage-backends.html" /> <link rel="prev" title="Important command line arguments" href="command-line.html" /> </head> <body> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="storage-backends.html" title="Storage backends" accesskey="N">next</a> |</li> <li class="right" > <a href="command-line.html" title="Important command line arguments" accesskey="P">previous</a> |</li> <li><a href="../index.html">Varnish version 4.0.0 documentation</a> &raquo;</li> <li><a href="index.html" >The Varnish Users Guide</a> &raquo;</li> <li><a href="running.html" accesskey="U">Starting and running Varnish</a> &raquo;</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="<API key>"> <span id="run-cli"></span><h1>CLI - bossing Varnish around<a class="headerlink" href=" <p>Once <cite>varnishd</cite> is started, you can control it using the command line interface.</p> <p>The easiest way to do this, is using <cite>varnishadm</cite> on the same machine as <cite>varnishd</cite> is running:</p> <div class="highlight-python"><pre>varnishadm help</pre> </div> <p>If you want to run <cite>varnishadm</cite> from a remote system, you can do it two ways.</p> <p>You can SSH into the <cite>varnishd</cite> computer and run <cite>varnishadm</cite>:</p> <div class="highlight-python"><pre>ssh $http_front_end varnishadm help</pre> </div> <p>But you can also configure <cite>varnishd</cite> to accept remote CLI connections (using the '-T' and '-S' arguments):</p> <div class="highlight-python"><pre>varnishd -T :6082 -S /etc/varnish_secret</pre> </div> <p>And then on the remote system run <cite>varnishadm</cite>:</p> <div class="highlight-python"><pre>varnishadm -T $http_front_end -S /etc/<API key> help</pre> </div> <p>but as you can see, SSH is much more convenient.</p> <p>If you run <cite>varnishadm</cite> without arguments, it will read CLI commands from <cite>stdin</cite>, if you give it arguments, it will treat those as the single CLI command to execute.</p> <p>The CLI always returns a status code to tell how it went: '200' means OK, anything else means there were some kind of trouble.</p> <p><cite>varnishadm</cite> will exit with status 1 and print the status code on standard error if it is not 200.</p> <div class="section" id="<API key>"> <h2>What can you do with the CLI<a class="headerlink" href=" <p>The CLI gives you almost total control over <cite>varnishd</cite> some of the more important tasks you can perform are:</p> <ul class="simple"> <li>load/use/discard VCL programs</li> <li>ban (invalidate) cache content</li> <li>change parameters</li> <li>start/stop worker process</li> </ul> <p>We will discuss each of these briefly below.</p> <div class="section" id="<API key>"> <h3>Load, use and discard VCL programs<a class="headerlink" href=" <p>All caching and policy decisions are made by VCL programs.</p> <p>You can have multiple VCL programs loaded, but one of them is designated the &quot;active&quot; VCL program, and this is where all new requests start out.</p> <p>To load new VCL program:</p> <div class="highlight-python"><pre>varnish&gt; vcl.load some_name some_filename</pre> </div> <p>Loading will read the VCL program from the file, and compile it. If the compilation fails, you will get an error messages:</p> <div class="highlight-python"><pre>.../mask is not numeric. ('input' Line 4 Pos 17) "192.168.2.0/24x", ------------- Running VCC-compiler failed, exit 1 VCL compilation failed</pre> </div> <p>If compilation succeeds, the VCL program is loaded, and you can now make it the active VCL, whenever you feel like it:</p> <div class="highlight-python"><pre>varnish&gt; vcl.use some_name</pre> </div> <p>If you find out that was a really bad idea, you can switch back to the previous VCL program again:</p> <div class="highlight-python"><pre>varnish&gt; vcl.use old_name</pre> </div> <p>The switch is instantaneous, all new requests will start using the VCL you activated right away. The requests currently being processed complete using whatever VCL they started with.</p> <p>It is good idea to design an emergency-VCL before you need it, and always have it loaded, so you can switch to it with a single vcl.use command.</p> </div> <div class="section" id="ban-cache-content"> <h3>Ban cache content<a class="headerlink" href=" <p>Varnish offers &quot;purges&quot; to remove things from cache, provided that you know exactly what they are.</p> <p>But sometimes it is useful to be able to throw things out of cache without having an exact list of what to throw out.</p> <p>Imagine for instance that the company logo changed and now you need Varnish to stop serving the old logo out of the cache:</p> <div class="highlight-python"><pre>varnish&gt; ban req.url ~ "logo.*[.]png"</pre> </div> <p>should do that, and yes, that is a regular expression.</p> <p>We call this &quot;banning&quot; because the objects are still in the cache, but they are banned from delivery.</p> <p>Instead of checking each and every cached object right away, we test each object against the regular expression only if and when an HTTP request asks for it.</p> <p>Banning stuff is much cheaper than restarting Varnish to get rid of wronly cached content.</p> </div> <div class="section" id="change-parameters"> <h3>Change parameters<a class="headerlink" href=" <p>Parameters can be set on the command line with the '-p' argument, but they can also be examined and changed on the fly from the CLI:</p> <div class="highlight-python"><pre>varnish&gt; param.show prefer_ipv6 200 prefer_ipv6 off [bool] Default is off Prefer IPv6 address when connecting to backends which have both IPv4 and IPv6 addresses. varnish&gt; param.set prefer_ipv6 true 200</pre> </div> <p>In general it is not a good idea to modify parameters unless you have a good reason, such as performance tuning or security configuration.</p> <p>Most parameters will take effect instantly, or with a natural delay of some duration,</p> <p>but a few of them requires you to restart the child process before they take effect. This is always noted in the description of the parameter.</p> </div> <div class="section" id="<API key>"> <h3>Starting and stopping the worker process<a class="headerlink" href=" <p>In general you should just leave the worker process running, but if you need to stop and/or start it, the obvious commands work:</p> <div class="highlight-python"><div class="highlight"><pre><span class="n">varnish</span><span class="o">&gt;</span> <span class="n">stop</span> </pre></div> </div> <p>and:</p> <div class="highlight-python"><div class="highlight"><pre><span class="n">varnish</span><span class="o">&gt;</span> <span class="n">start</span> </pre></div> </div> <p>If you start <cite>varnishd</cite> with the '-d' (debugging) argument, you will always need to start the child process explicitly.</p> <p>Should the child process die, the master process will automatically restart it, but you can disable that with the 'auto_restart' parameter.</p> </div> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="<API key>"> <h3><a href="../index.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">CLI - bossing Varnish around</a><ul> <li><a class="reference internal" href="#<API key>">What can you do with the CLI</a><ul> <li><a class="reference internal" href="#<API key>">Load, use and discard VCL programs</a></li> <li><a class="reference internal" href="#ban-cache-content">Ban cache content</a></li> <li><a class="reference internal" href="#change-parameters">Change parameters</a></li> <li><a class="reference internal" href="#<API key>">Starting and stopping the worker process</a></li> </ul> </li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="command-line.html" title="previous chapter">Important command line arguments</a></p> <h4>Next topic</h4> <p class="topless"><a href="storage-backends.html" title="next chapter">Storage backends</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../_sources/users-guide/run_cli.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="storage-backends.html" title="Storage backends" >next</a> |</li> <li class="right" > <a href="command-line.html" title="Important command line arguments" >previous</a> |</li> <li><a href="../index.html">Varnish version 4.0.0 documentation</a> &raquo;</li> <li><a href="index.html" >The Varnish Users Guide</a> &raquo;</li> <li><a href="running.html" >Starting and running Varnish</a> &raquo;</li> </ul> </div> <div class="footer"> &copy; Copyright 2010-2014, Varnish Software AS. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. </div> </body> </html>
var searchData= [ ['lcd_2ec',['lcd.c',['../lcd_8c.html',1,'']]], ['lcd_2eh',['lcd.h',['../lcd_8h.html',1,'']]], ['light_2ec',['light.c',['../light_8c.html',1,'']]], ['light_2eh',['light.h',['../light_8h.html',1,'']]] ];
using System; using System.Collections.Generic; using System.Linq; using MatterHackers.VectorMath; namespace MatterHackers.PolygonMesh { public static class FaceBspTree { private static readonly double considerCoplaner = .1; <summary> This function will search for the first face that produces no polygon cuts and split the tree on it. If it can't find a non-cutting face, it will split on the face that minimizes the area that it divides. </summary> <param name="mesh"></param> <returns></returns> public static BspNode Create(Mesh mesh, int maxFacesToTest = 10, bool tryToBalanceTree = false) { BspNode root = new BspNode(); var sourceFaces = Enumerable.Range(0, mesh.Faces.Count).ToList(); var faces = Enumerable.Range(0, mesh.Faces.Count).ToList(); <API key>(mesh, sourceFaces, root, faces, maxFacesToTest, tryToBalanceTree); return root; } <summary> Get an ordered list of the faces to render based on the camera position. </summary> <param name="node"></param> <param name="meshToViewTransform"></param> <param name="<API key>"></param> <param name="faceRenderOrder"></param> public static IEnumerable<int> <API key>(Mesh mesh, BspNode root, Matrix4X4 meshToViewTransform, Matrix4X4 <API key>) { var renderOrder = new Stack<BspNode>(new BspNode[] { root.RenderOrder(mesh, meshToViewTransform, <API key>) }); do { var lastBack = renderOrder.Peek().BackNode; while (lastBack != null && lastBack.Index != -1) { renderOrder.Peek().BackNode = null; renderOrder.Push(lastBack.RenderOrder(mesh, meshToViewTransform, <API key>)); lastBack = renderOrder.Peek().BackNode; } var node = renderOrder.Pop(); if (node.Index != -1) { yield return node.Index; } var lastFront = node.FrontNode; if (lastFront != null && lastFront.Index != -1) { renderOrder.Push(lastFront.RenderOrder(mesh, meshToViewTransform, <API key>)); } } while (renderOrder.Any()); } private static (double, int) <API key>(Mesh mesh, int faceIndex, List<int> faces, double <API key>) { double negativeDistance = 0; double positiveDistance = 0; int negativeSideCount = 0; int positiveSideCount = 0; int checkFace = faces[faceIndex]; var pointOnCheckFace = mesh.Vertices[mesh.Faces[faces[faceIndex]].v0]; for (int i = 0; i < faces.Count; i++) { if (i < faces.Count && i != faceIndex) { var iFace = mesh.Faces[faces[i]]; var vertexIndices = new int[] { iFace.v0, iFace.v1, iFace.v2 }; foreach (var vertexIndex in vertexIndices) { double distanceToPlan = mesh.Faces[checkFace].normal.Dot(mesh.Vertices[vertexIndex] - pointOnCheckFace); if (Math.Abs(distanceToPlan) > considerCoplaner) { if (distanceToPlan < 0) { // Take the square of this distance to penalize far away points negativeDistance += (distanceToPlan * distanceToPlan); } else { positiveDistance += (distanceToPlan * distanceToPlan); } if (negativeDistance > <API key> && positiveDistance > <API key>) { return (double.MaxValue, int.MaxValue); } } } if (negativeDistance > positiveDistance) { negativeSideCount++; } else { positiveSideCount++; } } } // return whatever side is small as our rating of badness (0 being good) return (Math.Min(negativeDistance, positiveDistance), Math.Abs(negativeSideCount - positiveSideCount)); } private static void <API key>(Mesh mesh, int faceIndex, List<int> faces, List<int> backFaces, List<int> frontFaces) { var checkFaceIndex = faces[faceIndex]; var checkFace = mesh.Faces[checkFaceIndex]; var pointOnCheckFace = mesh.Vertices[mesh.Faces[checkFaceIndex].v0]; for (int i = 0; i < faces.Count; i++) { if (i != faceIndex) { bool backFace = true; var vertexIndices = new int[] { checkFace.v0, checkFace.v1, checkFace.v2 }; foreach (var vertexIndex in vertexIndices) { double distanceToPlan = mesh.Faces[checkFaceIndex].normal.Dot(mesh.Vertices[vertexIndex] - pointOnCheckFace); if (Math.Abs(distanceToPlan) > considerCoplaner) { if (distanceToPlan > 0) { backFace = false; } } } if (backFace) { // it is a back face backFaces.Add(faces[i]); } else { // it is a front face frontFaces.Add(faces[i]); } } } } private static void <API key>(Mesh mesh, List<int> sourceFaces, BspNode node, List<int> faces, int maxFacesToTest, bool tryToBalanceTree) { if (faces.Count == 0) { return; } int bestFaceIndex = -1; double <API key> = double.MaxValue; int bestBalance = int.MaxValue; // find the first face that does not split anything int step = Math.Max(1, faces.Count / maxFacesToTest); for (int i = 0; i < faces.Count; i += step) { // calculate how much of polygons cross this face (double crossingArrea, int balance) = <API key>(mesh, i, faces, <API key>); // keep track of the best face so far if (crossingArrea < <API key>) { <API key> = crossingArrea; bestBalance = balance; bestFaceIndex = i; if (crossingArrea == 0 && !tryToBalanceTree) { break; } } else if (crossingArrea == <API key> && balance < bestBalance) { // the crossing area is the same but the tree balance is better bestBalance = balance; bestFaceIndex = i; } } node.Index = sourceFaces.IndexOf(faces[bestFaceIndex]); // put the behind stuff in a list var backFaces = new List<int>(); var frontFaces = new List<int>(); <API key>(mesh, bestFaceIndex, faces, backFaces, frontFaces); <API key>(mesh, sourceFaces, node.BackNode = new BspNode(), backFaces, maxFacesToTest, tryToBalanceTree); <API key>(mesh, sourceFaces, node.FrontNode = new BspNode(), frontFaces, maxFacesToTest, tryToBalanceTree); } } public class BspNode { public BspNode BackNode { get; internal set; } public BspNode FrontNode { get; internal set; } public int Index { get; internal set; } = -1; } public static class BspNodeExtensions { public static BspNode RenderOrder(this BspNode node, Mesh mesh, Matrix4X4 meshToViewTransform, Matrix4X4 <API key>) { var <API key> = mesh.Faces[node.Index].normal.<API key>(<API key>); var <API key> = mesh.Vertices[mesh.Faces[node.Index].v0].Transform(meshToViewTransform); var infrontOfFace = <API key>.Dot(<API key>) < 0; if (infrontOfFace) { return new BspNode() { Index = node.Index, BackNode = node.BackNode, FrontNode = node.FrontNode }; } else { return new BspNode() { Index = node.Index, BackNode = node.FrontNode, FrontNode = node.BackNode }; } } } }
using System; using System.Reflection; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; namespace LabVIEW_CLI { class Program { static bool connected = false; static bool stop = false; static int Main(string[] args) { int exitCode = 0; Output output = Output.Instance; string[] cliArgs, lvArgs; lvComms lvInterface = new lvComms(); lvMsg latestMessage = new lvMsg("NOOP", ""); LvLauncher launcher = null; CliOptions options = new CliOptions(); lvVersion current = LvVersions.CurrentVersion; splitArguments(args, out cliArgs, out lvArgs); //CommandLine.Parser.Default.ParseArguments(cliArgs, options); if(!CommandLine.Parser.Default.ParseArguments(cliArgs, options)) { Environment.Exit(CommandLine.Parser.DefaultExitCodeFail); } if (options.Version) { output.writeMessage(Assembly.<API key>().GetName().Version.ToString()); Environment.Exit(0); } output.setVerbose(options.Verbose); output.writeInfo("LabVIEW CLI Started - Verbose Mode"); output.writeInfo("Version " + Assembly.<API key>().GetName().Version); output.writeInfo("LabVIEW CLI Arguments: " + String.Join(" ", cliArgs)); output.writeInfo("Arguments passed to LabVIEW: " + String.Join(" ", lvArgs)); if (options.noLaunch) { output.writeMessage("Auto Launch Disabled"); // disable timeout if noLaunch is specified options.timeout = -1; } else { // check launch vi if(options.LaunchVI == null) { output.writeError("No launch VI supplied!"); return 1; } if (!File.Exists(options.LaunchVI)) { output.writeError("File \"" + options.LaunchVI + "\" does not exist!"); return 1; } List<string> permittedExtensions = new List<string>{ ".vi", ".lvproj" }; string ext = Path.GetExtension(options.LaunchVI).ToLower(); if (!permittedExtensions.Contains(ext)) { output.writeError("Cannot handle *" + ext + " files"); return 1; } try { launcher = new LvLauncher(options.LaunchVI, lvPathFinder(options), lvInterface.port, lvArgs); launcher.Exited += Launcher_Exited; launcher.Start(); } catch(<API key> ex) { // Fail gracefully if lv-ver option cannot be resolved string bitness = options.x64 ? " 64bit" : string.Empty; output.writeError("LabVIEW version \"" + options.lvVer + bitness + "\" not found!"); output.writeMessage("Available LabVIEW versions are:"); foreach(var ver in LvVersions.Versions) { output.writeMessage(ver.ToString()); } return 1; } catch(<API key> ex) { output.writeError(ex.Message); return 1; } } // wait for the LabVIEW application to connect to the cli connected = lvInterface.waitOnConnection(options.timeout); // if timed out, kill LabVIEW and exit with error code if (!connected && launcher!=null) { output.writeError("Connection to LabVIEW timed out!"); launcher.Kill(); launcher.Exited -= Launcher_Exited; return 1; } do { latestMessage = lvInterface.readMessage(); switch (latestMessage.messageType) { case "OUTP": Console.Write(latestMessage.messageData); break; case "EXIT": exitCode = lvInterface.extractExitCode(latestMessage.messageData); output.writeMessage("Recieved Exit Code " + exitCode); stop = true; break; case "RDER": exitCode = 1; output.writeError("Read Error"); stop = true; break; default: output.writeError("Unknown Message Type Recieved:" + latestMessage.messageType); break; } } while (!stop); lvInterface.Close(); return exitCode; } private static void Launcher_Exited(object sender, EventArgs e) { // Just quit by force if the tcp connection was not established or if LabVIEW exited without sending "EXIT" or "RDER" if (!connected || !stop) { Output output = Output.Instance; output.writeError("LabVIEW terminated unexpectedly!"); Environment.Exit(1); } } private static void splitArguments(string[] args, out string[] cliArgs, out string[] lvArgs) { int splitterLocation = -1; for(int i = 0; i < args.Length; i++) { if(args[i] == " { splitterLocation = i; } } if(splitterLocation > 0) { cliArgs = args.Take(splitterLocation).ToArray(); lvArgs = args.Skip(splitterLocation + 1).ToArray(); } else { cliArgs = args; lvArgs = new string[0]; } } private static string lvPathFinder(CliOptions options) { if (options.lvExe != null) { if (!File.Exists(options.lvExe)) throw new <API key>("specified executable not found", options.lvExe); return options.lvExe; } if (options.lvVer != null) { try { return LvVersions.<API key>(options.lvVer, options.x64).ExePath; } catch(<API key> ex) { throw; // So the exception makes it to the handler above. } } if (LvVersions.CurrentVersion != null) { return LvVersions.CurrentVersion.ExePath; } else { throw new <API key>("No LabVIEW.exe found...", "LabVIEW.exe"); } } } }
from celery.task import Task import requests class StracksFlushTask(Task): def run(self, url, data): requests.post(url + "/", data=data)
package com.ferox.math.bounds; import com.ferox.math.*; /** * <p/> * Frustum represents the mathematical construction of a frustum. It is described as a 6 sided convex hull, * where at least two planes are parallel to each other. It supports generating frustums that represent * perspective projections (a truncated pyramid), or orthographic projections (a rectangular prism). * <p/> * Each frustum has a direction vector and an up vector. These vectors define an orthonormal basis for the * frustum. The two parallel planes of the frustum are specified as distances along the direction vector (near * and far). The additional planes are computed based on the locations of the four corners of the near plane * intersection. * <p/> * The mapping from world space to frustum space is not as straight-forward as is implied by the above state. * Frustum provides the functionality to get the {@link #getProjectionMatrix() project matrix} and {@link * #getViewMatrix() modelview matrix} suitable for use in an OpenGL system. The camera within an OpenGL system * looks down its local negative z-axis. Thus the provided direction in this Frustum represents the negative * z-axis within camera space. * * @author Michael Ludwig */ public class Frustum { /** * Result of a frustum test against a {@link AxisAlignedBox}. */ public static enum FrustumIntersection { /** * Returned when a candidate object is fully enclosed by the Frustum. */ INSIDE, /** * Returned when a candidate object is completely outside of the Frustum. */ OUTSIDE, /** * Returned when a candidate object intersects the Frustum but is not completely contained. */ INTERSECT } public static final int NUM_PLANES = 6; public static final int NEAR_PLANE = 0; public static final int FAR_PLANE = 1; public static final int TOP_PLANE = 2; public static final int BOTTOM_PLANE = 3; public static final int LEFT_PLANE = 4; public static final int RIGHT_PLANE = 5; private boolean useOrtho; // local values private double frustumLeft; private double frustumRight; private double frustumTop; private double frustumBottom; private double frustumNear; private double frustumFar; // frustum orientation private final Vector3 up; private final Vector3 direction; private final Vector3 location; private final Matrix4 projection; private final Matrix4 view; // planes representing frustum, adjusted for // position, direction and up private final Vector4[] worldPlanes; // temporary vector used during intersection queries, saved to avoid allocation private final Vector3 temp; /** * Instantiate a new Frustum that's positioned at the origin, looking down the negative z-axis. The given * values are equivalent to those described in setPerspective() and are used for the initial frustum * parameters. * * @param fov * @param aspect * @param znear * @param zfar */ public Frustum(double fov, double aspect, double znear, double zfar) { this(); setPerspective(fov, aspect, znear, zfar); } /** * Instantiate a new Frustum that's positioned at the origin, looking down the negative z-axis. The six * values are equivalent to those specified in setFrustum() and are taken as the initial frustum * parameters. * * @param ortho True if the frustum values are for an orthographic projection, otherwise it's a * perspective projection * @param fl * @param fr * @param fb * @param ft * @param fn * @param ff */ public Frustum(boolean ortho, double fl, double fr, double fb, double ft, double fn, double ff) { this(); setFrustum(ortho, fl, fr, fb, ft, fn, ff); } // initialize everything private Frustum() { worldPlanes = new Vector4[6]; location = new Vector3(); up = new Vector3(0, 1, 0); direction = new Vector3(0, 0, -1); view = new Matrix4(); projection = new Matrix4(); temp = new Vector3(); } /** * Get the left edge of the near frustum plane. * * @return The left edge of the near frustum plane * * @see #setFrustum(boolean, double, double, double, double, double, double) */ public double getFrustumLeft() { return frustumLeft; } /** * Get the right edge of the near frustum plane. * * @return The right edge of the near frustum plane * * @see #setFrustum(boolean, double, double, double, double, double, double) */ public double getFrustumRight() { return frustumRight; } /** * Get the top edge of the near frustum plane. * * @return The top edge of the near frustum plane * * @see #setFrustum(boolean, double, double, double, double, double, double) */ public double getFrustumTop() { return frustumTop; } /** * Get the bottom edge of the near frustum plane. * * @return The bottom edge of the near frustum plane * * @see #setFrustum(boolean, double, double, double, double, double, double) */ public double getFrustumBottom() { return frustumBottom; } /** * Get the distance to the near frustum plane from the origin, in camera coords. * * @return The distance to the near frustum plane * * @see #setFrustum(boolean, double, double, double, double, double, double) */ public double getFrustumNear() { return frustumNear; } /** * Get the distance to the far frustum plane from the origin, in camera coords. * * @return The distance to the far frustum plane * * @see #setFrustum(boolean, double, double, double, double, double, double) */ public double getFrustumFar() { return frustumFar; } /** * <p/> * Sets the dimensions of the viewing frustum in camera coords. left, right, bottom, and top specify edges * of the rectangular near plane. This plane is positioned perpendicular to the viewing direction, a * distance near along the direction vector from the view's location. * <p/> * If this Frustum is using orthogonal projection, the frustum is a rectangular prism extending from this * near plane, out to an identically sized plane, that is distance far away. If not, the far plane is the * far extent of a pyramid with it's point at the location, truncated at the near plane. * * @param ortho True if the Frustum should use an orthographic projection * @param left The left edge of the near frustum plane * @param right The right edge of the near frustum plane * @param bottom The bottom edge of the near frustum plane * @param top The top edge of the near frustum plane * @param near The distance to the near frustum plane * @param far The distance to the far frustum plane * * @throws <API key> if left > right, bottom > top, near > far, or near <= 0 when the view * isn't orthographic */ public void setFrustum(boolean ortho, double left, double right, double bottom, double top, double near, double far) { if (left > right || bottom > top || near > far) { throw new <API key>("Frustum values would create an invalid frustum: " + left + " " + right + " x " + bottom + " " + top + " x " + near + " " + far); } if (near <= 0 && !ortho) { throw new <API key>("Illegal value for near frustum when using perspective projection: " + near); } frustumLeft = left; frustumRight = right; frustumBottom = bottom; frustumTop = top; frustumNear = near; frustumFar = far; useOrtho = ortho; update(); } /** * Set the frustum to be perspective projection with the given field of view (in degrees). Widths and * heights are calculated using the assumed aspect ration and near and far values. Because perspective * transforms only make sense for non-orthographic projections, it also sets this view to be * non-orthographic. * * @param fov The field of view * @param aspect The aspect ratio of the view region (width / height) * @param near The distance from the view's location to the near camera plane * @param far The distance from the view's location to the far camera plane * * @throws <API key> if fov is outside of (0, 180], or aspect is <= 0, or near > far, or if * near <= 0 */ public void setPerspective(double fov, double aspect, double near, double far) { if (fov <= 0f || fov > 180f) { throw new <API key>("Field of view must be in (0, 180], not: " + fov); } if (aspect <= 0) { throw new <API key>("Aspect ration must be >= 0, not: " + aspect); } double h = Math.tan(Math.toRadians(fov * .5f)) * near; double w = h * aspect; setFrustum(false, -w, w, -h, h, near, far); } /** * Set the frustum to be an orthographic projection that uses the given boundary edges for the near * frustum plane. The near value is set to -1, and the far value is set to 1. * * @param left * @param right * @param bottom * @param top * * @throws <API key> if left > right or bottom > top * @see #setFrustum(boolean, double, double, double, double, double, double) */ public void setOrtho(double left, double right, double bottom, double top) { setFrustum(true, left, right, bottom, top, -1f, 1f); } /** * Whether or not this view uses a perspective or orthogonal projection. * * @return True if the projection matrix is orthographic */ public boolean <API key>() { return useOrtho; } /** * <p/> * Get the location vector of this view, in world space. The returned vector is read-only. Modifications * to the frustum's view parameters must be done through {@link #setOrientation(Vector3, Vector3, * Vector3)}. * * @return The location of the view */ public @Const Vector3 getLocation() { return location; } /** * <p/> * Get the up vector of this view, in world space. Together up and direction form a right-handed * coordinate system. The returned vector is read-only. Modifications to the frustum's view parameters * must be done through {@link #setOrientation(Vector3, Vector3, Vector3)}. * * @return The up vector of this view */ public @Const Vector3 getUp() { return up; } /** * <p/> * Get the direction vector of this frustum, in world space. Together up and direction form a right-handed * coordinate system. The returned vector is read-only. Modifications to the frustum's view parameters * must be done through {@link #setOrientation(Vector3, Vector3, Vector3)}. * * @return The current direction that this frustum is pointing */ public @Const Vector3 getDirection() { return direction; } /** * Compute and return the field of view along the vertical axis that this Frustum uses. This is * meaningless for an orthographic projection, and returns -1 in that case. Otherwise, an angle in degrees * is returned in the range 0 to 180. This works correctly even when the bottom and top edges of the * Frustum are not centered about its location. * * @return The field of view of this Frustum */ public double getFieldOfView() { if (useOrtho) { return -1f; } double fovTop = Math.atan(frustumTop / frustumNear); double fovBottom = Math.atan(frustumBottom / frustumNear); return Math.toDegrees(fovTop - fovBottom); } /** * <p/> * Return the 4x4 projection matrix that represents the mathematical projection from the frustum to * homogenous device coordinates (essentially the unit cube). * <p/> * <p/> * The returned matrix is read-only and will be updated automatically as the projection of the Frustum * changes. * * @return The projection matrix */ public @Const Matrix4 getProjectionMatrix() { return projection; } /** * <p/> * Return the 'view' transform of this Frustum. The view transform represents the coordinate space * transformation from world space to camera/frustum space. The local basis of the Frustum is formed by * the left, up and direction vectors of the Frustum. The left vector is <code>up X direction</code>, and * up and direction are user defined vectors. * <p/> * The returned matrix is read-only and will be updated automatically as {@link #setOrientation(Vector3, * Vector3, Vector3)} is invoked. * * @return The view matrix */ public @Const Matrix4 getViewMatrix() { return view; } /** * <p/> * Copy the given vectors into this Frustum for its location, direction and up vectors. The orientation is * then normalized and orthogonalized, but the provided vectors are unmodified. * <p/> * Any later changes to the vectors' x, y, and z values will not be reflected in the frustum planes or * view transform, unless this method is called again. * * @param location The new location vector * @param direction The new direction vector * @param up The new up vector * * @throws <API key> if location, direction or up is null */ public void setOrientation(@Const Vector3 location, @Const Vector3 direction, @Const Vector3 up) { if (location == null || direction == null || up == null) { throw new <API key>("Orientation vectors cannot be null: " + location + " " + direction + " " + up); } this.location.set(location); this.direction.set(direction); this.up.set(up); update(); } /** * Set the orientation of this Frustum based on the affine <var>transform</var>. The 4th column's first 3 * values encode the transformation. The 3rd column holds the direction vector, and the 2nd column defines * the up vector. * * @param transform The new transform of the frustum * * @throws <API key> if transform is null */ public void setOrientation(@Const Matrix4 transform) { if (transform == null) { throw new <API key>("Transform cannot be null"); } this.location.set(transform.m03, transform.m13, transform.m23); this.direction.set(transform.m02, transform.m12, transform.m22); this.up.set(transform.m01, transform.m11, transform.m21); update(); } /** * Set the orientation of this Frustum based on the given location vector and 3x3 rotation matrix. * Together the vector and rotation represent an affine transform that is treated the same as in {@link * #setOrientation(Matrix4)}. * * @param location The location of the frustum * @param rotation The rotation of the frustum * * @throws <API key> if location or rotation are null */ public void setOrientation(@Const Vector3 location, @Const Matrix3 rotation) { if (location == null) { throw new <API key>("Location cannot be null"); } if (rotation == null) { throw new <API key>("Rotation matrix cannot be null"); } this.location.set(location); this.direction.set(rotation.m02, rotation.m12, rotation.m22); this.up.set(rotation.m01, rotation.m11, rotation.m21); update(); } /** * <p/> * Return a plane representing the given plane of the view frustum, in world coordinates. This plane * should not be modified. The returned plane's normal is configured so that it points into the center of * the Frustum. The returned {@link Vector4} is encoded as a plane as defined in {@link Plane}; it is also * normalized. * <p/> * <p/> * The returned plane vector is read-only. It will be updated automatically when the projection or view * parameters change. * * @param i The requested plane index * * @return The ReadOnlyVector4f instance for the requested plane, in world coordinates * * @throws <API key> if plane isn't in [0, 5] */ public @Const Vector4 getFrustumPlane(int i) { return worldPlanes[i]; } /** * <p/> * Compute and return the intersection of the AxisAlignedBox and this Frustum, <var>f</var>. It is assumed * that the Frustum and AxisAlignedBox exist in the same coordinate frame. {@link * FrustumIntersection#INSIDE} is returned when the AxisAlignedBox is fully contained by the Frustum. * {@link FrustumIntersection#INTERSECT} is returned when this box is partially contained by the Frustum, * and {@link FrustumIntersection#OUTSIDE} is returned when the box has no intersection with the Frustum. * <p/> * If <var>OUTSIDE</var> is returned, it is guaranteed that the objects enclosed by the bounds do not * intersect the Frustum. If <var>INSIDE</var> is returned, any object {@link * AxisAlignedBox#contains(AxisAlignedBox) contained} by the box will also be completely inside the * Frustum. When <var>INTERSECT</var> is returned, there is a chance that the true representation of the * objects enclosed by the box will be outside of the Frustum, but it is unlikely. This can occur when a * corner of the box intersects with the planes of <var>f</var>, but the shape does not exist in that * corner. * <p/> * The argument <var>planeState</var> can be used to hint to this function which planes of the Frustum * require checking and which do not. When a hierarchy of bounds is used, the planeState can be used to * remove unnecessary plane comparisons. If <var>planeState</var> is null it is assumed that all planes * need to be checked. If <var>planeState</var> is not null, this method will mark any plane that the box * is completely inside of as not requiring a comparison. It is the responsibility of the caller to save * and restore the plane state as needed based on the structure of the bound hierarchy. * * @param bounds The bounds to test for intersection with this frustm * @param planeState An optional PlaneState hint specifying which planes to check * * @return A FrustumIntersection indicating how the frustum and bounds intersect * * @throws <API key> if bounds is null */ public FrustumIntersection intersects(@Const AxisAlignedBox bounds, PlaneState planeState) { if (bounds == null) { throw new <API key>("Bounds cannot be null"); } // early escape for potentially deeply nested nodes in a tree if (planeState != null && !planeState.getTestsRequired()) { return FrustumIntersection.INSIDE; } FrustumIntersection result = FrustumIntersection.INSIDE; double distMax; double distMin; int plane = 0; Vector4 p; for (int i = Frustum.NUM_PLANES - 1; i >= 0; i if (planeState == null || planeState.isTestRequired(i)) { p = getFrustumPlane(plane); // set temp to the normal of the plane then compute the extent // in-place; this is safe but we'll have to reset temp to the // normal later if needed temp.set(p.x, p.y, p.z).farExtent(bounds, temp); distMax = Plane.getSignedDistance(p, temp, true); if (distMax < 0) { // the point closest to the plane is behind the plane, so // we know the bounds must be outside of the frustum return FrustumIntersection.OUTSIDE; } else { // the point closest to the plane is in front of the plane, // but we need to check the farthest away point // make sure to reset temp to the normal before computing // the near extent in-place temp.set(p.x, p.y, p.z).nearExtent(bounds, temp); distMin = Plane.getSignedDistance(p, temp, true); if (distMin < 0) { // the farthest point is behind the plane, so at best // this box will be intersecting the frustum result = FrustumIntersection.INTERSECT; } else { // the box is completely contained by the plane, so // the return result can be INSIDE or INTERSECT (if set by another plane) if (planeState != null) { planeState.setTestRequired(plane, false); } } } } } return result; } /* * Update the plane instances returned by getFrustumPlane() to reflect any * changes to the frustum's local parameters or orientation. Also update the * view transform and projection matrix. */ private void update() { // compute the right-handed basis vectors of the frustum Vector3 n = new Vector3().scale(direction.normalize(), -1); // normalizes direction as well Vector3 u = new Vector3().cross(up, n).normalize(); Vector3 v = up.cross(n, u).normalize(); // recompute up to properly orthogonal to direction // view matrix view.set(u.x, u.y, u.z, -location.dot(u), v.x, v.y, v.z, -location.dot(v), n.x, n.y, n.z, -location.dot(n), 0f, 0f, 0f, 1f); // projection matrix if (useOrtho) { projection.set(2 / (frustumRight - frustumLeft), 0, 0, -(frustumRight + frustumLeft) / (frustumRight - frustumLeft), 0, 2 / (frustumTop - frustumBottom), 0, -(frustumTop + frustumBottom) / (frustumTop - frustumBottom), 0, 0, 2 / (frustumNear - frustumFar), -(frustumFar + frustumNear) / (frustumFar - frustumNear), 0, 0, 0, 1); } else { projection.set(2 * frustumNear / (frustumRight - frustumLeft), 0, (frustumRight + frustumLeft) / (frustumRight - frustumLeft), 0, 0, 2 * frustumNear / (frustumTop - frustumBottom), (frustumTop + frustumBottom) / (frustumTop - frustumBottom), 0, 0, 0, -(frustumFar + frustumNear) / (frustumFar - frustumNear), -2 * frustumFar * frustumNear / (frustumFar - frustumNear), 0, 0, -1, 0); } // generate world-space frustum planes, we pass in n and u since we // created them to compute the view matrix and they're just garbage // at this point, might as well let plane generation reuse them. if (useOrtho) { <API key>(n, u); } else { <API key>(n, u); } } private void <API key>(Vector3 n, Vector3 p) { // FAR p.scale(direction, frustumFar).add(location); n.scale(direction, -1); setWorldPlane(FAR_PLANE, n, p); // NEAR p.scale(direction, frustumNear).add(location); n.set(direction); setWorldPlane(NEAR_PLANE, n, p); // compute right vector for LEFT and RIGHT usage n.cross(direction, up); // LEFT p.scale(n, frustumLeft).add(location); setWorldPlane(LEFT_PLANE, n, p); // RIGHT p.scale(n, frustumRight).add(location); n.scale(-1); setWorldPlane(RIGHT_PLANE, n, p); // BOTTOM p.scale(up, frustumBottom).add(location); setWorldPlane(BOTTOM_PLANE, up, p); // TOP n.scale(up, -1); p.scale(up, frustumTop).add(location); setWorldPlane(TOP_PLANE, n, p); } private void <API key>(Vector3 n, Vector3 p) { // FAR p.scale(direction, frustumFar).add(location); p.scale(direction, -1); setWorldPlane(FAR_PLANE, n, p); // NEAR p.scale(direction, frustumNear).add(location); n.set(direction); setWorldPlane(NEAR_PLANE, n, p); // compute left vector for LEFT and RIGHT usage p.cross(up, direction); // LEFT double invHyp = 1 / Math.sqrt(frustumNear * frustumNear + frustumLeft * frustumLeft); n.scale(direction, Math.abs(frustumLeft) / frustumNear).sub(p).scale(frustumNear * invHyp); setWorldPlane(LEFT_PLANE, n, location); // RIGHT invHyp = 1 / Math.sqrt(frustumNear * frustumNear + frustumRight * frustumRight); n.scale(direction, Math.abs(frustumRight) / frustumNear).add(p).scale(frustumNear * invHyp); setWorldPlane(RIGHT_PLANE, n, location); // BOTTOM invHyp = 1 / Math.sqrt(frustumNear * frustumNear + frustumBottom * frustumBottom); n.scale(direction, Math.abs(frustumBottom) / frustumNear).add(up).scale(frustumNear * invHyp); setWorldPlane(BOTTOM_PLANE, n, location); // TOP invHyp = 1 / Math.sqrt(frustumNear * frustumNear + frustumTop * frustumTop); n.scale(direction, Math.abs(frustumTop) / frustumNear).sub(up).scale(frustumNear * invHyp); setWorldPlane(TOP_PLANE, n, location); } // set the given world plane so it's a plane with the given normal // that passes through pos, and then normalize it private void setWorldPlane(int plane, @Const Vector3 normal, @Const Vector3 pos) { setWorldPlane(plane, normal.x, normal.y, normal.z, -normal.dot(pos)); } // set the given world plane, with the 4 values, and then normalize it private void setWorldPlane(int plane, double a, double b, double c, double d) { Vector4 cp = worldPlanes[plane]; if (cp == null) { cp = new Vector4(a, b, c, d); worldPlanes[plane] = cp; } else { cp.set(a, b, c, d); } Plane.normalize(cp); } }
module Convert.LRChirotope where -- standard modules import Data.List import qualified Data.Map as Map import Data.Maybe import qualified Data.Set as Set -- local modules import Basics import Calculus.FlipFlop import Helpful.General --import Debug.Trace { - FlipFlop to Chirotope <API key> :: Network [String] (ARel FlipFlop) -> Maybe (Network [Int] Int) <API key> net | isNothing net5 || isNothing net3 = Nothing | otherwise = Just $ (fromJust net3) { nCons = fst $ Map.foldlWithKey collectOneCon (Map.empty, Map.empty) cons } where collectOneCon (consAcc, mapAcc) nodes rel = let (newMap, convertedNodes) = mapAccumL (\ m node -> let mappedNode = Map.lookup node m in case mappedNode of Nothing -> let n = (Map.size m) + 1 in (Map.insert node n m, n) otherwise -> (m, fromJust mappedNode) ) mapAcc nodes newRel = case aRel rel of R -> (-1) I -> 0 L -> 1 in ( foldl (flip $ uncurry Map.insert) consAcc $ [(x, newRel * y) | (x,y) <- <API key> 3 convertedNodes ] , newMap ) net5 = ffsToFF5s net net3 = ff5sToFF3s $ fromJust net5 cons = nCons $ fromJust net3
Some tips for using linspecer I personally like the first color to be black, so I begin with: colors = [0,0,0; linspecer(10)]; which creates an 11x3 matrix of RGB colors. Note: you must add the linspecer to your path via: addpath('~\<API key>/linspecer') you can add this to the startup.m file, found in your default startup directory for Matlab (on my Mac it's at `/Users/USERNAME/Documents/MATLAB/`) If you'd like Matlab to use this color order by default, add this code to your startup.m file: addpath('~/path-to-linspecer/linspecer') colors = [0,0,0; linspecer(8)]; set(0,'<API key>',colors); where `'~/path-to-linspecer/linspecer'` is the path to you `linspecer` folder.
var files = [ [ "Code", "<API key>.html", "<API key>" ] ];
{-# LANGUAGE FlexibleContexts #-} module BRC.Solver.Error where import Control.Monad.Error (Error(..), MonadError(..)) -- | Solver errors, really just a container for a possibly useful error message. data SolverError = SolverError String deriving (Eq, Ord) instance Show (SolverError) where show (SolverError msg) = "Solver error: " ++ msg instance Error SolverError where strMsg = SolverError -- | Throws an error with a given message in a solver error monad. solverError :: MonadError SolverError m => String -> m a solverError = throwError . strMsg
package cocoonClient.Panels; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.event.ListSelectionEvent; import javax.swing.table.DefaultTableModel; import <API key>.newReader.JSONReader; import cocoonClient.Connector.AbstractConnector; import cocoonClient.Data.UserInfo; public class StatusPanel extends CocoonDisplayPanel implements AbstractConnector{ private JTable table; public StatusPanel(){ super(UserInfo.getMainFrame()); setRightPanel(new TestRightPanel()); this.setSize(600, 500); this.setLayout(new FlowLayout()); init(); UserInfo.getPanels().put("Status", this); } private void init() { try{ //Table//ModelJTable table = new JTable(){ public void valueChanged(ListSelectionEvent e){ super.valueChanged(e); //valueChanged(), if( table.getSelectedRow() == -1) return; } }; table.setModel(new DefaultTableModel(){ @Override public boolean isCellEditable(int row, int column){ return false; } }); table.setShowGrid(true); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.<API key>(Color.ORANGE); table.<API key>(true); //Model, DefaultTableModel dtm = (DefaultTableModel)table.getModel(); //TableModel String columnTitle[] = new String[]{"Date", "Username", "Problem", "Status"}; int columnWidth[] = new int[]{150, 120, 190, 120}; for(int i = 0; i < columnTitle.length; i++){ dtm.addColumn(columnTitle[i]); } for(int i = 0; i < columnWidth.length; i++){ table.getColumnModel().getColumn(i).setPreferredWidth(columnWidth[i]); } //JTableMouseEvent /* table.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e){ int selRow = table.rowAtPoint(e.getPoint());// String Size = (String) table.getValueAt(selRow, 2); //3 if (Integer.parseInt(Size)> 0 ){ } } });*/ }catch ( Exception e){ e.printStackTrace(); } JScrollPane pane = new JScrollPane(table); pane.setPreferredSize(new Dimension(600, 450)); add(pane); } private void addStatus(String response){ JSONReader reader = new JSONReader(response); DefaultTableModel dtm = (DefaultTableModel)table.getModel(); String result = ""; try{ result = reader.getSubmission().getResult().split("\n")[0]; } catch(Exception e){} dtm.addRow(new String[] { reader.getSubmission().getTime(), reader.getSubmission().getUsername(), UserInfo.getProblemSet().getProblemName(reader.getSubmission().getPID()), result }); } @Override public void recieveResponse(String response) { addStatus(response); } }
<!DOCTYPE HTML PUBLIC "- <!-- NewPage --> <html lang="en"> <head> <!-- Generated by javadoc (version 1.7.0_51) on Fri Mar 06 12:54:17 CET 2015 --> <meta http-equiv="Content-Type" content="text/html" charset="UTF-8"> <title>Trash.Mode</title> <meta name="date" content="2015-03-06"> <link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style"> </head> <body> <script type="text/javascript"><! if (location.href.indexOf('is-external=true') == -1) { parent.document.title="Trash.Mode"; } </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <div class="topNav"><a name="navbar_top"> </a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow"> </a> <ul class="navList" title="Navigation"> <li><a href="../../../overview-summary.html">Overview</a></li> <li><a href="package-summary.html">Package</a></li> <li class="navBarCell1Rev">Class</li> <li><a href="package-tree.html">Tree</a></li> <li><a href="../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../index-all.html">Index</a></li> <li><a href="../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../../org/jetel/component/Trash.html" title="class in org.jetel.component"><span class="strong">Prev Class</span></a></li> <li><a href="../../../org/jetel/component/TreeReader.html" title="class in org.jetel.component"><span class="strong">Next Class</span></a></li> </ul> <ul class="navList"> <li><a href="../../../index.html?org/jetel/component/Trash.Mode.html" target="_top">Frames</a></li> <li><a href="Trash.Mode.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="<API key>"> <li><a href="../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><! allClassesLink = document.getElementById("<API key>"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } </script> </div> <div> <ul class="subNavList"> <li>Summary:&nbsp;</li> <li>Nested&nbsp;|&nbsp;</li> <li><a href="#<API key>">Enum Constants</a>&nbsp;|&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li><a href="#method_summary">Method</a></li> </ul> <ul class="subNavList"> <li>Detail:&nbsp;</li> <li><a href="#<API key>">Enum Constants</a>&nbsp;|&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li><a href="#method_detail">Method</a></li> </ul> </div> <a name="skip-navbar_top"> </a></div> <div class="header"> <div class="subTitle">org.jetel.component</div> <h2 title="Enum Trash.Mode" class="title">Enum Trash.Mode</h2> </div> <div class="contentContainer"> <ul class="inheritance"> <li>java.lang.Object</li> <li> <ul class="inheritance"> <li>java.lang.Enum&lt;<a href="../../../org/jetel/component/Trash.Mode.html" title="enum in org.jetel.component">Trash.Mode</a>&gt;</li> <li> <ul class="inheritance"> <li>org.jetel.component.Trash.Mode</li> </ul> </li> </ul> </li> </ul> <div class="description"> <ul class="blockList"> <li class="blockList"> <dl> <dt>All Implemented Interfaces:</dt> <dd>java.io.Serializable, java.lang.Comparable&lt;<a href="../../../org/jetel/component/Trash.Mode.html" title="enum in org.jetel.component">Trash.Mode</a>&gt;</dd> </dl> <dl> <dt>Enclosing class:</dt> <dd><a href="../../../org/jetel/component/Trash.html" title="class in org.jetel.component">Trash</a></dd> </dl> <hr> <br> <pre>public static enum <span class="strong">Trash.Mode</span> extends java.lang.Enum&lt;<a href="../../../org/jetel/component/Trash.Mode.html" title="enum in org.jetel.component">Trash.Mode</a>&gt;</pre> </li> </ul> </div> <div class="summary"> <ul class="blockList"> <li class="blockList"> <ul class="blockList"> <li class="blockList"><a name="<API key>"> </a> <h3>Enum Constant Summary</h3> <table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Enum Constant Summary table, listing enum constants, and an explanation"> <caption><span>Enum Constants</span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colOne" scope="col">Enum Constant and Description</th> </tr> <tr class="altColor"> <td class="colOne"><code><strong><a href="../../../org/jetel/component/Trash.Mode.html#PERFORMANCE">PERFORMANCE</a></strong></code>&nbsp;</td> </tr> <tr class="rowColor"> <td class="colOne"><code><strong><a href="../../../org/jetel/component/Trash.Mode.html#VALIDATE_RECORDS">VALIDATE_RECORDS</a></strong></code>&nbsp;</td> </tr> </table> </li> </ul> <ul class="blockList"> <li class="blockList"><a name="method_summary"> </a> <h3>Method Summary</h3> <table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation"> <caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colLast" scope="col">Method and Description</th> </tr> <tr class="altColor"> <td class="colFirst"><code>static <a href="../../../org/jetel/component/Trash.Mode.html" title="enum in org.jetel.component">Trash.Mode</a></code></td> <td class="colLast"><code><strong><a href="../../../org/jetel/component/Trash.Mode.html#valueOf(java.lang.String)">valueOf</a></strong>(java.lang.String&nbsp;name)</code> <div class="block">Returns the enum constant of this type with the specified name.</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><code>static <a href="../../../org/jetel/component/Trash.Mode.html" title="enum in org.jetel.component">Trash.Mode</a>[]</code></td> <td class="colLast"><code><strong><a href="../../../org/jetel/component/Trash.Mode.html#values()">values</a></strong>()</code> <div class="block">Returns an array containing the constants of this enum type, in the order they are declared.</div> </td> </tr> </table> <ul class="blockList"> <li class="blockList"><a name="<API key>.lang.Enum"> </a> <h3>Methods inherited from class&nbsp;java.lang.Enum</h3> <code>clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf</code></li> </ul> <ul class="blockList"> <li class="blockList"><a name="<API key>.lang.Object"> </a> <h3>Methods inherited from class&nbsp;java.lang.Object</h3> <code>getClass, notify, notifyAll, wait, wait, wait</code></li> </ul> </li> </ul> </li> </ul> </div> <div class="details"> <ul class="blockList"> <li class="blockList"> <ul class="blockList"> <li class="blockList"><a name="<API key>"> </a> <h3>Enum Constant Detail</h3> <a name="VALIDATE_RECORDS"> </a> <ul class="blockList"> <li class="blockList"> <h4>VALIDATE_RECORDS</h4> <pre>public static final&nbsp;<a href="../../../org/jetel/component/Trash.Mode.html" title="enum in org.jetel.component">Trash.Mode</a> VALIDATE_RECORDS</pre> </li> </ul> <a name="PERFORMANCE"> </a> <ul class="blockListLast"> <li class="blockList"> <h4>PERFORMANCE</h4> <pre>public static final&nbsp;<a href="../../../org/jetel/component/Trash.Mode.html" title="enum in org.jetel.component">Trash.Mode</a> PERFORMANCE</pre> </li> </ul> </li> </ul> <ul class="blockList"> <li class="blockList"><a name="method_detail"> </a> <h3>Method Detail</h3> <a name="values()"> </a> <ul class="blockList"> <li class="blockList"> <h4>values</h4> <pre>public static&nbsp;<a href="../../../org/jetel/component/Trash.Mode.html" title="enum in org.jetel.component">Trash.Mode</a>[]&nbsp;values()</pre> <div class="block">Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows: <pre> for (Trash.Mode c : Trash.Mode.values()) &nbsp; System.out.println(c); </pre></div> <dl><dt><span class="strong">Returns:</span></dt><dd>an array containing the constants of this enum type, in the order they are declared</dd></dl> </li> </ul> <a name="valueOf(java.lang.String)"> </a> <ul class="blockListLast"> <li class="blockList"> <h4>valueOf</h4> <pre>public static&nbsp;<a href="../../../org/jetel/component/Trash.Mode.html" title="enum in org.jetel.component">Trash.Mode</a>&nbsp;valueOf(java.lang.String&nbsp;name)</pre> <div class="block">Returns the enum constant of this type with the specified name. The string must match <i>exactly</i> an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)</div> <dl><dt><span class="strong">Parameters:</span></dt><dd><code>name</code> - the name of the enum constant to be returned.</dd> <dt><span class="strong">Returns:</span></dt><dd>the enum constant with the specified name</dd> <dt><span class="strong">Throws:</span></dt> <dd><code>java.lang.<API key></code> - if this enum type has no constant with the specified name</dd> <dd><code>java.lang.<API key></code> - if the argument is null</dd></dl> </li> </ul> </li> </ul> </li> </ul> </div> </div> <div class="bottomNav"><a name="navbar_bottom"> </a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="<API key>"> </a> <ul class="navList" title="Navigation"> <li><a href="../../../overview-summary.html">Overview</a></li> <li><a href="package-summary.html">Package</a></li> <li class="navBarCell1Rev">Class</li> <li><a href="package-tree.html">Tree</a></li> <li><a href="../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../index-all.html">Index</a></li> <li><a href="../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../../org/jetel/component/Trash.html" title="class in org.jetel.component"><span class="strong">Prev Class</span></a></li> <li><a href="../../../org/jetel/component/TreeReader.html" title="class in org.jetel.component"><span class="strong">Next Class</span></a></li> </ul> <ul class="navList"> <li><a href="../../../index.html?org/jetel/component/Trash.Mode.html" target="_top">Frames</a></li> <li><a href="Trash.Mode.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="<API key>"> <li><a href="../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><! allClassesLink = document.getElementById("<API key>"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } </script> </div> <div> <ul class="subNavList"> <li>Summary:&nbsp;</li> <li>Nested&nbsp;|&nbsp;</li> <li><a href="#<API key>">Enum Constants</a>&nbsp;|&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li><a href="#method_summary">Method</a></li> </ul> <ul class="subNavList"> <li>Detail:&nbsp;</li> <li><a href="#<API key>">Enum Constants</a>&nbsp;|&nbsp;</li> <li>Field&nbsp;|&nbsp;</li> <li><a href="#method_detail">Method</a></li> </ul> </div> <a name="skip-navbar_bottom"> </a></div> <p class="legalCopy"><small> <address>Copyright &#169; 2002-2015 Javlin a.s.</address> </small></p> </body> </html>
package com.iteamsolutions.angular.models.atom import scalaz.{ Failure => _, Success => _, _ } * The '''Link''' type is the Domain Object Model representation of an final case class Link ( val href : URI, val rel : String \/ URI, val title : Option[String] ) { } object Link { }
package de.lman; import de.lman.engine.Colors; import de.lman.engine.Game; import de.lman.engine.InputState; import de.lman.engine.Keys; import de.lman.engine.Mouse; import de.lman.engine.math.Mat2f; import de.lman.engine.math.Scalar; import de.lman.engine.math.Transform; import de.lman.engine.math.Vec2f; import de.lman.engine.physics.Body; import de.lman.engine.physics.ContactStatePair; import de.lman.engine.physics.GeometryUtils; import de.lman.engine.physics.Physics; import de.lman.engine.physics.contacts.Contact; import de.lman.engine.physics.contacts.ContactListener; import de.lman.engine.physics.shapes.BoxShape; import de.lman.engine.physics.shapes.EdgeShape; import de.lman.engine.physics.shapes.PhysicsMaterial; import de.lman.engine.physics.shapes.PlaneShape; import de.lman.engine.physics.shapes.PolygonShape; import de.lman.engine.physics.shapes.Shape; public class Leverman extends Game implements ContactListener { public Leverman() { super("Leverman"); } public static void main(String[] args) { Leverman game = new Leverman(); game.run(); } private Physics physics; private boolean showContacts = true; private boolean showAABBs = false; private boolean physicsSingleStep = false; public final static PhysicsMaterial MAT_STATIC = new PhysicsMaterial(0f, 0.1f); public final static PhysicsMaterial MAT_DYNAMIC = new PhysicsMaterial(1f, 0.1f); private Body playerBody; private boolean playerOnGround = false; private boolean playerJumping = false; private int playerGroundHash = 0; private final Vec2f groundNormal = new Vec2f(0, 1); @Override public void physicsBeginContact(int hash, ContactStatePair pair) { Contact contact = pair.pair.contacts[pair.contactIndex]; Vec2f normal = contact.normal; Body player = null; if (pair.pair.a.id == playerBody.id) { player = pair.pair.a; normal = new Vec2f(contact.normal).invert(); } else if (pair.pair.b.id == playerBody.id) { player = pair.pair.b; } float d = normal.dot(groundNormal); if (d > 0) { if (player != null && (!playerOnGround)) { playerOnGround = true; playerGroundHash = hash; } } } @Override public void physicsEndContact(int hash, ContactStatePair pair) { Contact contact = pair.pair.contacts[pair.contactIndex]; Vec2f normal = contact.normal; Body player = null; if (pair.pair.a.id == playerBody.id) { player = pair.pair.a; normal = new Vec2f(contact.normal).invert(); } else if (pair.pair.b.id == playerBody.id) { player = pair.pair.b; } float d = normal.dot(groundNormal); if (d > 0) { if (player != null && playerOnGround && (playerGroundHash == hash)) { playerOnGround = false; playerGroundHash = 0; } } } private void addPlatform(float x, float y, float rx, float ry) { Body body; physics.addBody(body = new Body().addShape(new BoxShape(new Vec2f(rx, ry)).setMaterial(MAT_STATIC))); body.pos.set(x, y); } private void addBox(float x, float y, float rx, float ry) { Body body; physics.addBody(body = new Body().addShape(new BoxShape(new Vec2f(rx, ry)).setMaterial(MAT_DYNAMIC))); body.pos.set(x, y); } protected void initGame() { physics = new Physics(this); physics.<API key>(physicsSingleStep); Body body; physics.addBody(body = new Body().addShape(new PlaneShape(viewport.y).rotation(Scalar.PI * 0f).setMaterial(MAT_STATIC))); body.pos.set(-halfWidth + 0.5f, 0); physics.addBody(body = new Body().addShape(new PlaneShape(viewport.y).rotation(Scalar.PI * 1f).setMaterial(MAT_STATIC))); body.pos.set(halfWidth - 0.5f, 0); physics.addBody(body = new Body().addShape(new PlaneShape(viewport.x).rotation(Scalar.PI * 0.5f).setMaterial(MAT_STATIC))); body.pos.set(0, -halfHeight + 0.5f); physics.addBody(body = new Body().addShape(new PlaneShape(viewport.x).rotation(Scalar.PI * 1.5f).setMaterial(MAT_STATIC))); body.pos.set(0, halfHeight - 0.5f); addPlatform(0 - 2.9f, 0 - 2.0f, 0.6f, 0.1f); addPlatform(0, 0 - 1.3f, 0.7f, 0.1f); addPlatform(0 + 2.9f, 0 - 0.8f, 0.6f, 0.1f); //addBox(0, -0.5f, 0.2f, 0.2f); addPlatform(0 + 2.0f, -halfHeight + 0.2f + 0.5f, 0.2f, 0.2f); addPlatform(0 + 2.4f, -halfHeight + 0.2f + 0.5f, 0.2f, 0.2f); addPlatform(0 + 2.8f, -halfHeight + 0.2f + 0.5f, 0.2f, 0.2f); addPlatform(0 + 3.2f, -halfHeight + 0.2f + 0.5f, 0.2f, 0.2f); playerBody = new Body(); BoxShape playerBox = (BoxShape) new BoxShape(new Vec2f(0.2f, 0.4f)).setMaterial(MAT_DYNAMIC); playerBody.addShape(playerBox); playerBody.pos.set(0, -halfHeight + playerBox.radius.y + 0.5f); physics.addBody(playerBody); Vec2f[] polyVerts = new Vec2f[]{ new Vec2f(0, 0.5f), new Vec2f(-0.5f, -0.5f), new Vec2f(0.5f, -0.5f), }; physics.addBody(body = new Body().addShape(new PolygonShape(polyVerts).setMaterial(MAT_STATIC))); body.pos.set(0, 0); } private boolean dragging = false; private Vec2f dragStart = new Vec2f(); private Body dragBody = null; private void updateGameInput(float dt, InputState inputState) { boolean leftMousePressed = inputState.isMouseDown(Mouse.LEFT); if (!dragging) { if (leftMousePressed) { dragBody = null; for (int i = 0; i < physics.numBodies; i++) { Body body = physics.bodies[i]; if (body.invMass > 0) { if (GeometryUtils.isPointInAABB(inputState.mousePos.x, inputState.mousePos.y, body.aabb)) { dragging = true; dragStart.set(inputState.mousePos); dragBody = body; break; } } } } } else { if (leftMousePressed) { float dx = inputState.mousePos.x - dragStart.x; float dy = inputState.mousePos.y - dragStart.y; dragBody.vel.x += dx * 0.1f; dragBody.vel.y += dy * 0.1f; dragStart.set(inputState.mousePos); } else { dragging = false; } } // Kontakte ein/ausschalten if (inputState.isKeyDown(Keys.F2)) { showContacts = !showContacts; inputState.setKeyDown(Keys.F2, false); } // AABBs ein/ausschalten if (inputState.isKeyDown(Keys.F3)) { showAABBs = !showAABBs; inputState.setKeyDown(Keys.F3, false); } // <API key> ein/ausschalten if (inputState.isKeyDown(Keys.F5)) { physicsSingleStep = !physicsSingleStep; physics.<API key>(physicsSingleStep); inputState.setKeyDown(Keys.F5, false); } if (inputState.isKeyDown(Keys.F6)) { if (physicsSingleStep) { physics.nextStep(); } inputState.setKeyDown(Keys.F6, false); } // Player bewegen if (inputState.isKeyDown(Keys.W)) { if (!playerJumping && playerOnGround) { playerBody.acc.y += 4f / dt; playerJumping = true; } } else { if (playerJumping && playerOnGround) { playerJumping = false; } } if (inputState.isKeyDown(Keys.A)) { playerBody.acc.x -= 0.1f / dt; } else if (inputState.isKeyDown(Keys.D)) { playerBody.acc.x += 0.1f / dt; } } private final Editor editor = new Editor(); private boolean editorWasShownAABB = false; protected void updateInput(float dt, InputState input) { // Editormodus ein/ausschalten if (input.isKeyDown(Keys.F4)) { editor.active = !editor.active; if (editor.active) { editorWasShownAABB = showAABBs; showAABBs = true; editor.init(physics); } else { showAABBs = editorWasShownAABB; } input.setKeyDown(Keys.F4, false); } if (editor.active) { editor.updateInput(dt, physics, input); } else { updateGameInput(dt, input); } } @Override protected String getAdditionalTitle() { return String.format(" [Frames: %d, Bodies: %d, Contacts: %d]", numFrames, physics.numBodies, physics.numContacts); } protected void updateGame(float dt) { if (!editor.active) { physics.step(dt); } } private void renderEditor(float dt) { // TODO: Move to editor class clear(0x000000); for (int i = 0; i < viewport.x / Editor.GRID_SIZE; i++) { drawLine(-halfWidth + i * Editor.GRID_SIZE, -halfHeight, -halfWidth + i * Editor.GRID_SIZE, halfHeight, Colors.DarkSlateGray); } for (int i = 0; i < viewport.y / Editor.GRID_SIZE; i++) { drawLine(-halfWidth, -halfHeight + i * Editor.GRID_SIZE, halfWidth, -halfHeight + i * Editor.GRID_SIZE, Colors.DarkSlateGray); } drawBodies(physics.numBodies, physics.bodies); if (editor.selectedBody != null) { Editor.DragSide[] dragSides = editor.getDragSides(editor.selectedBody); Shape shape = editor.selectedBody.shapes[0]; if (dragSides.length > 0 && shape instanceof EdgeShape) { EdgeShape edgeShape = (EdgeShape) shape; Transform t = new Transform(shape.localPos, shape.localRotation).offset(editor.selectedBody.pos); Vec2f[] localVertices = edgeShape.getLocalVertices(); for (int i = 0; i < dragSides.length; i++) { Vec2f dragPoint = dragSides[i].center; drawPoint(dragPoint, Editor.DRAGPOINT_RADIUS, Colors.White); if (editor.resizeSideIndex == i) { Vec2f v0 = new Vec2f(localVertices[dragSides[i].index0]).transform(t); Vec2f v1 = new Vec2f(localVertices[dragSides[i].index1]).transform(t); drawPoint(v0, Editor.DRAGPOINT_RADIUS, Colors.GoldenRod); drawPoint(v1, Editor.DRAGPOINT_RADIUS, Colors.GoldenRod); } } } Mat2f mat = new Mat2f(shape.localRotation).transpose(); drawNormal(editor.selectedBody.pos, mat.col1, <API key>, <API key>, Colors.Red); } drawPoint(inputState.mousePos.x, inputState.mousePos.y, <API key>, 0x0000FF); } private void renderInternalGame(float dt) { clear(0x000000); drawBodies(physics.numBodies, physics.bodies); if (showAABBs) { drawAABBs(physics.numBodies, physics.bodies); } if (showContacts) { drawContacts(dt, physics.numPairs, physics.pairs, false, true); } } protected void renderGame(float dt) { if (editor.active) { renderEditor(dt); } else { renderInternalGame(dt); } } }
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} module NW.Monster where import NW.Stats data MonsterClass = MCFighter | MCMage deriving (Eq, Show) data Monster = Monster { mClass :: MonsterClass , mName :: String , mStatsBase :: [Stat] , mLootBonus :: Int } deriving (Eq, Show) type MonsterDB = [Monster]
package org.jvnet.jaxb2_commons.plugin.mergeable; import java.util.Arrays; import java.util.Collection; import javax.xml.namespace.QName; import org.jvnet.jaxb2_commons.lang.JAXBMergeStrategy; import org.jvnet.jaxb2_commons.lang.MergeFrom2; import org.jvnet.jaxb2_commons.lang.MergeStrategy2; import org.jvnet.jaxb2_commons.locator.ObjectLocator; import org.jvnet.jaxb2_commons.locator.util.LocatorUtils; import org.jvnet.jaxb2_commons.plugin.<API key>; import org.jvnet.jaxb2_commons.plugin.Customizations; import org.jvnet.jaxb2_commons.plugin.CustomizedIgnoring; import org.jvnet.jaxb2_commons.plugin.Ignoring; import org.jvnet.jaxb2_commons.plugin.util.FieldOutlineUtils; import org.jvnet.jaxb2_commons.plugin.util.StrategyClassUtils; import org.jvnet.jaxb2_commons.util.ClassUtils; import org.jvnet.jaxb2_commons.util.<API key>; import org.jvnet.jaxb2_commons.util.<API key>; import org.jvnet.jaxb2_commons.xjc.outline.FieldAccessorEx; import org.xml.sax.ErrorHandler; import com.sun.codemodel.JBlock; import com.sun.codemodel.JCodeModel; import com.sun.codemodel.JConditional; import com.sun.codemodel.JDefinedClass; import com.sun.codemodel.JExpr; import com.sun.codemodel.JExpression; import com.sun.codemodel.JMethod; import com.sun.codemodel.JMod; import com.sun.codemodel.JOp; import com.sun.codemodel.JType; import com.sun.codemodel.JVar; import com.sun.tools.xjc.Options; import com.sun.tools.xjc.outline.ClassOutline; import com.sun.tools.xjc.outline.FieldOutline; import com.sun.tools.xjc.outline.Outline; public class MergeablePlugin extends <API key> { @Override public String getOptionName() { return "Xmergeable"; } @Override public String getUsage() { return "TBD"; } private <API key> <API key> = <API key>.INSTANCE; public <API key> <API key>() { return <API key>; } public void <API key>( <API key> <API key>) { this.<API key> = <API key>; } private String mergeStrategyClass = JAXBMergeStrategy.class.getName(); public void <API key>(final String mergeStrategyClass) { this.mergeStrategyClass = mergeStrategyClass; } public String <API key>() { return mergeStrategyClass; } public JExpression createMergeStrategy(JCodeModel codeModel) { return StrategyClassUtils.<API key>(codeModel, MergeStrategy2.class, <API key>()); } private Ignoring ignoring = new CustomizedIgnoring( org.jvnet.jaxb2_commons.plugin.mergeable.Customizations.<API key>, Customizations.<API key>, Customizations.<API key>); public Ignoring getIgnoring() { return ignoring; } public void setIgnoring(Ignoring ignoring) { this.ignoring = ignoring; } @Override public Collection<QName> <API key>() { return Arrays .asList(org.jvnet.jaxb2_commons.plugin.mergeable.Customizations.<API key>, Customizations.<API key>, Customizations.<API key>); } @Override public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) { for (final ClassOutline classOutline : outline.getClasses()) if (!getIgnoring().isIgnored(classOutline)) { processClassOutline(classOutline); } return true; } protected void processClassOutline(ClassOutline classOutline) { final JDefinedClass theClass = classOutline.implClass; ClassUtils ._implements(theClass, theClass.owner().ref(MergeFrom2.class)); @SuppressWarnings("unused") final JMethod mergeFrom$mergeFrom0 = generateMergeFrom$mergeFrom0( classOutline, theClass); @SuppressWarnings("unused") final JMethod mergeFrom$mergeFrom = generateMergeFrom$mergeFrom( classOutline, theClass); if (!classOutline.target.isAbstract()) { @SuppressWarnings("unused") final JMethod createCopy = generateMergeFrom$createNewInstance( classOutline, theClass); } } protected JMethod generateMergeFrom$mergeFrom0( final ClassOutline classOutline, final JDefinedClass theClass) { JCodeModel codeModel = theClass.owner(); final JMethod mergeFrom$mergeFrom = theClass.method(JMod.PUBLIC, codeModel.VOID, "mergeFrom"); mergeFrom$mergeFrom.annotate(Override.class); { final JVar left = mergeFrom$mergeFrom.param(Object.class, "left"); final JVar right = mergeFrom$mergeFrom.param(Object.class, "right"); final JBlock body = mergeFrom$mergeFrom.body(); final JVar mergeStrategy = body.decl(JMod.FINAL, codeModel.ref(MergeStrategy2.class), "strategy", createMergeStrategy(codeModel)); body.invoke("mergeFrom").arg(JExpr._null()).arg(JExpr._null()) .arg(left).arg(right).arg(mergeStrategy); } return mergeFrom$mergeFrom; } protected JMethod generateMergeFrom$mergeFrom(ClassOutline classOutline, final JDefinedClass theClass) { final JCodeModel codeModel = theClass.owner(); final JMethod mergeFrom = theClass.method(JMod.PUBLIC, codeModel.VOID, "mergeFrom"); mergeFrom.annotate(Override.class); { final JVar leftLocator = mergeFrom.param(ObjectLocator.class, "leftLocator"); final JVar rightLocator = mergeFrom.param(ObjectLocator.class, "rightLocator"); final JVar left = mergeFrom.param(Object.class, "left"); final JVar right = mergeFrom.param(Object.class, "right"); final JVar mergeStrategy = mergeFrom.param(MergeStrategy2.class, "strategy"); final JBlock methodBody = mergeFrom.body(); Boolean <API key> = StrategyClassUtils .<API key>(classOutline, getIgnoring(), MergeFrom2.class); if (<API key> == null) { } else if (<API key>.booleanValue()) { methodBody.invoke(JExpr._super(), "mergeFrom").arg(leftLocator) .arg(rightLocator).arg(left).arg(right) .arg(mergeStrategy); } else { } final FieldOutline[] declaredFields = FieldOutlineUtils.filter( classOutline.getDeclaredFields(), getIgnoring()); if (declaredFields.length > 0) { final JBlock body = methodBody._if(right._instanceof(theClass)) ._then(); JVar target = body.decl(JMod.FINAL, theClass, "target", JExpr._this()); JVar leftObject = body.decl(JMod.FINAL, theClass, "leftObject", JExpr.cast(theClass, left)); JVar rightObject = body.decl(JMod.FINAL, theClass, "rightObject", JExpr.cast(theClass, right)); for (final FieldOutline fieldOutline : declaredFields) { final FieldAccessorEx leftFieldAccessor = <API key>() .createFieldAccessor(fieldOutline, leftObject); final FieldAccessorEx rightFieldAccessor = <API key>() .createFieldAccessor(fieldOutline, rightObject); if (leftFieldAccessor.isConstant() || rightFieldAccessor.isConstant()) { continue; } final JBlock block = body.block(); final JExpression <API key> = (leftFieldAccessor .isAlwaysSet() || leftFieldAccessor.hasSetValue() == null) ? JExpr.TRUE : leftFieldAccessor.hasSetValue(); final JExpression <API key> = (rightFieldAccessor .isAlwaysSet() || rightFieldAccessor.hasSetValue() == null) ? JExpr.TRUE : rightFieldAccessor.hasSetValue(); final JVar shouldBeSet = block.decl( codeModel.ref(Boolean.class), fieldOutline.getPropertyInfo().getName(false) + "<API key>", mergeStrategy.invoke("<API key>") .arg(leftLocator).arg(rightLocator) .arg(<API key>) .arg(<API key>)); final JConditional <API key> = block._if(JOp .eq(shouldBeSet, codeModel.ref(Boolean.class) .staticRef("TRUE"))); final JBlock ifShouldBeSetBlock = <API key> ._then(); final JConditional <API key> = <API key> ._elseif(JOp.eq( shouldBeSet, codeModel.ref(Boolean.class).staticRef( "FALSE"))); final JBlock <API key> = <API key> ._then(); // final JBlock <API key> = // <API key> // ._else(); final JVar leftField = ifShouldBeSetBlock.decl( leftFieldAccessor.getType(), "lhs" + fieldOutline.getPropertyInfo().getName( true)); leftFieldAccessor.toRawValue(ifShouldBeSetBlock, leftField); final JVar rightField = ifShouldBeSetBlock.decl( rightFieldAccessor.getType(), "rhs" + fieldOutline.getPropertyInfo().getName( true)); rightFieldAccessor.toRawValue(ifShouldBeSetBlock, rightField); final JExpression leftFieldLocator = codeModel .ref(LocatorUtils.class).staticInvoke("property") .arg(leftLocator) .arg(fieldOutline.getPropertyInfo().getName(false)) .arg(leftField); final JExpression rightFieldLocator = codeModel .ref(LocatorUtils.class).staticInvoke("property") .arg(rightLocator) .arg(fieldOutline.getPropertyInfo().getName(false)) .arg(rightField); final FieldAccessorEx targetFieldAccessor = <API key>() .createFieldAccessor(fieldOutline, target); final JExpression mergedValue = JExpr.cast( targetFieldAccessor.getType(), mergeStrategy.invoke("merge").arg(leftFieldLocator) .arg(rightFieldLocator).arg(leftField) .arg(rightField).arg(<API key>) .arg(<API key>)); final JVar merged = ifShouldBeSetBlock.decl( rightFieldAccessor.getType(), "merged" + fieldOutline.getPropertyInfo().getName( true), mergedValue); targetFieldAccessor.fromRawValue( ifShouldBeSetBlock, "unique" + fieldOutline.getPropertyInfo().getName( true), merged); targetFieldAccessor.unsetValues(<API key>); } } } return mergeFrom; } protected JMethod generateMergeFrom$createNewInstance( final ClassOutline classOutline, final JDefinedClass theClass) { final JMethod existingMethod = theClass.getMethod("createNewInstance", new JType[0]); if (existingMethod == null) { final JMethod newMethod = theClass.method(JMod.PUBLIC, theClass .owner().ref(Object.class), "createNewInstance"); newMethod.annotate(Override.class); { final JBlock body = newMethod.body(); body._return(JExpr._new(theClass)); } return newMethod; } else { return existingMethod; } } }
using System; using System.Collections.Generic; using System.Drawing; using DevExpress.XtraBars; namespace bv.winclient.Core.TranslationTool { public partial class PropertyGrid : BvForm { public ControlDesigner SourceControl { get; private set; } public ControlModel Model { get; private set; } public PropertyGrid() { InitializeComponent(); } public void <API key>(<API key> sourceControl) { rowCaption.Visible = categoryLocation.Visible = categorySize.Visible = false; categoryMenuItems.Visible = true; Model = new ControlModel { CanCaptionChange = false }; foreach (var o in sourceControl) { var caption = String.Empty; if (o is BarSubItemLink) { caption = ((BarSubItemLink) o).Item.Caption; } else if (o is <API key>) { caption = ((<API key>) o).Item.Caption; } if (caption.Length == 0) continue; Model.MenuItems.Add(caption); } propGrid.SelectedObject = Model; } public void <API key>(ControlDesigner sourceControl) { SourceControl = sourceControl; var control = SourceControl.RealControl; Model = new ControlModel { X = control.Location.X, Y = control.Location.Y, Width = control.Size.Width, Height = control.Size.Height, CanCaptionChange = <API key>.IsEditableControl(control) }; if (Model.CanCaptionChange) { Model.OldCaption = Model.Caption = <API key>.GetComponentText(control); } else { rowCaption.Visible = false; } if (SourceControl.MovingEnabled) { Model.OldLocation = control.Location; } else { categoryLocation.Visible = false; } if (SourceControl.SizingEnabled) { Model.OldSize = control.Size; } else { categorySize.Visible = false; } //we create a list with all menu items if (control is PopUpButton) { var pb = (PopUpButton) control; foreach (BarButtonItemLink action in pb.PopupActions.ItemLinks) { Model.MenuItems.Add(action.Item.Caption); } categoryMenuItems.Visible = true; } else { categoryMenuItems.Visible = false; } propGrid.SelectedObject = Model; } private void bCancel_Click(object sender, EventArgs e) { Close(); } private void BOk_Click(object sender, EventArgs e) { //todo validation? Close(); } } public class ControlModel { public string Caption { get; set; } public int X { get; set; } public int Y { get; set; } public int Width { get; set; } public int Height { get; set; } public bool CanCaptionChange { get; set; } public Point OldLocation { get; set; } public Size OldSize { get; set; } public string OldCaption { get; set; } public List<string> MenuItems { get; set; } public ControlModel() { Caption = String.Empty; OldCaption = String.Empty; X = Y = Width = Height = 0; CanCaptionChange = false; OldLocation = new Point(0, 0); OldSize = new Size(0, 0); MenuItems = new List<string>(); } public bool IsLocationChanged() { return new Point(X, Y) != OldLocation; } public bool IsSizeChanged() { return new Size(Width, Height) != OldSize; } public bool IsCaptionChanged() { return Caption != OldCaption; } } }
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('freebasics', '<API key>'), ] operations = [ migrations.AddField( model_name='<API key>', name='postgres_db_url', field=models.TextField(null=True, blank=True), ), ]
// modification, are permitted provided that the following conditions // are met: // the documentation and/or other materialsprovided with the // distribution. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. #pragma once #include "value.hh" namespace wrencc { class Compiler; FunctionObject* compile(WrenVM& vm, ModuleObject* module, const str_t& source_bytes, bool is_expression = false, bool print_errors = false); void mark_compiler(WrenVM& vm, Compiler* compiler); }