Skip to content

Instantly share code, notes, and snippets.

View BetterProgramming's full-sized avatar

BetterProgramming

View GitHub Profile
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"PUT",
"POST"
],
package wsc;
// Depending on wsdl chosen, change this to enterprise or partner
import com.sforce.soap.enterprise.*;
import com.sforce.soap.enterprise.sobject.*;
import com.sforce.ws.*;
public class Main {
public static void main(String[] args) {
ConnectorConfig credentials = new ConnectorConfig();
credentials.setPassword("YourPassword!apPenDdedSecurityToken);
credentials.setUsername("yoursalesforceusername@yourdomain.com");
typedef struct CError {
int code;
char* message;
} CError;
typedef enum EitherType {
intValue = 0,
stringValue = 1
} EitherType;
typedef struct Either {
CError* error;
/*
StateDispatcher is declared in C header file. C Function and struct declarations can used directly in Swift. They are mapped to corresponding Swift types.
*/
var stateDispatcherFunc: StateDispatcher = { callerPointer, state in
if let unwrappedPointer = callerPointer {
// ARC related, please ignore for now.
let wrapper = Unmanaged<SpeechCoreWrapper>
.fromOpaque(unwrappedPointer).takeUnretainedValue()
// example from the beginning of this article
DispatchQueue.main.async {
val stateJob = flowToCallback(
adapterScope, speechRecognizerStateFlow,
speechRecognizerStateCallback
)
fun <T> flowToCallback(scope: CoroutineScope, flow: Flow<T>,
callback: Consumer<T>): Job {
return scope.launch {
try {
flow.collect {
// invokes the closure which will call C calback
import org.graalvm.nativeimage.c.struct.SizeOf;
import static org.graalvm.nativeimage.UnmanagedMemory.calloc;
import static org.graalvm.nativeimage.UnmanagedMemory.malloc;
public static CSpeechBusinessData allocData() {
// malloc() initializes only. allocated space is dirty.
CSpeechBusinessData csbd = malloc(
SizeOf.get(CSpeechBusinessData.class)
);
return csbd;
@CContext(Headers.class)
public class NativeInterface {
public static class Headers implements CContext.Directives {
@Override
public List<String> getHeaderFiles() {
return Collections.unmodifiableList(
Arrays.asList("header.h")
)
}
}
// allocate create isolate arguments
let isolate = UnsafeMutablePointer<OpaquePointer?>
.allocate(capacity: 1)
let params = UnsafeMutablePointer<graal_create_isolate_params_t>
.allocate(capacity: 1)
let graal_thread = UnsafeMutablePointer<OpaquePointer?>
.allocate(capacity: 1)
// create isolate
let ret = graal_create_isolate(self.params, self.isolate, graal_thread)
if ret != 0 {
<!DOCTYPE html> <!-- Declaring that's that the file is html-->
<html lang="en"> <!-- Showing that the document is in English--><head><title>JavaScript - read JSON from URL</title>
<!-- Importing JQuery-->
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
</head>
<body>
<div class="entree0"></div>
<script>
const today = new Date();
const yyyy = today.getFullYear();
const today = new Date();
const yyyy = today.getFullYear();
let mm = today.getMonth() + 1; // Months start at 0!
let dd = today.getDate();
var todayy = new Date();
if (dd < 10) dd = '0' + dd;
if (mm < 10) mm = '0' + mm;
const formattedToday = mm + '/' + dddd + '/' + yyyy;
mylink = "https://www.sagedining.com/microsites/getMenuItems?menuId=110277&date=" + formattedToday + "&meal=Lunch";
console.log(mylink)