Skip to content

Instantly share code, notes, and snippets.

@agentcoops
agentcoops / cuda_11.8_installation_on_Ubuntu_22.04
Last active March 29, 2024 03:56 — forked from MihailCosmin/cuda_11.8_installation_on_Ubuntu_22.04
Instructions for CUDA v11.8 and cuDNN 8.7 installation on (wsl) Ubuntu 22.04 for PyTorch 2.0.0
#!/bin/bash
### steps ####
# verify the system has a cuda-capable gpu
# download and install the nvidia cuda toolkit and cudnn
# setup environmental variables
# verify the installation
###
### to verify your gpu is cuda enable check
@agentcoops
agentcoops / ios7.swift
Created September 24, 2015 22:19
IOS 7 Swift
func paymentAuthorizationViewController(
controller: PKPaymentAuthorizationViewController,
didAuthorizePayment payment: PKPayment,
completion: ((PKPaymentAuthorizationStatus) -> Void)) {
self.handlePaymentAuthorizationWithPayment(payment, completion:completion);
}
func handlePaymentAuthorizationWithPayment(payment: PKPayment, completion: ((PKPaymentAuthorizationStatus) -> Void)!) {
STPAPIClient.sharedClient().createTokenWithPayment(
@agentcoops
agentcoops / ViewController.swift
Created September 13, 2015 08:33
ViewController.swift
//
// ViewController.swift
// testingstripe
//
// Created by Charles Francis on 5/22/15.
// Copyright (c) 2015 Charles Francis. All rights reserved.
import UIKit
class ViewController: UIViewController, PKPaymentAuthorizationViewControllerDelegate {
Stripe.api_key = # your API key
nextCharges = Stripe::Charge.all(:limit => 100)
data = nextCharges.data
while nextCharges.has_more do
nextCharges = Stripe::Charge.all(:limit => 100, :starting_after => data[data.length - 1].id)
data = data + nextCharges.data
end
data.inject(0) {| sum, nextCharge | sum + nextCharge.amount }
@agentcoops
agentcoops / gist:ec24f824fcdd36bd4963
Created August 23, 2015 16:13
Pharo Stripe Request
| znc response |
ZnNetworkingUtils defaultSocketStreamTimeout: 60.
(znc := ZnClient new) logToTranscript.
response := znc
url: 'https://api.stripe.com/v1/charges';
headerAt: 'Authorization'
add: ('BEARER {1}' format: { <YOUR KEY> });
formAt: 'amount' put: '1000';
Dim StripeURL, APIKey
StripeURL = "https://api.stripe.com/v1/charges"
APIKey = <YOUR SECRET KEY>
Function makeStripeAPICall(requestBody)
Dim objXmlHttpMain
Set objXmlHttpMain = CreateObject("Msxml2.ServerXMLHTTP")
On Error Resume Next
objXmlHttpMain.open "POST", StripeURL, False
// From the repl:
scala> val features: Seq[Array[FeatureNode]] = values._2
features: Seq[Array[liblinear.FeatureNode]] = List(Array(FeatureNode(idx=1, value=1.0)), Array(FeatureNode(idx=2, value=1.0)))
scala> features.toArray
res5: Array[Array[liblinear.FeatureNode]] = Array(Array(FeatureNode(idx=1, value=1.0)), Array(FeatureNode(idx=2, value=1.0)))
// But when this is otherwise executed:
[info] null (TraversableOnce.scala:388)
[info] scala.collection.TraversableOnce$class.toArray(TraversableOnce.scala:388)
[info] scala.collection.immutable.List.toArray(List.scala:45)
> lst
[,1] [,2] [,3]
[1,] "3" "2" "1"
> table(lst, lst)
Error in sort.list(y) :
'x' must be atomic for 'sort.list'
Have you called 'sort' on a list?
> traceback()
4: stop("'x' must be atomic for 'sort.list'\nHave you called 'sort' on a list?")
3: sort.list(y)
java.lang.NullPointerException
at scala.Array$$anon$2.apply(Array.scala:46)
at scala.Array$$anon$2.apply(Array.scala:45)
at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:226)
at scala.collection.mutable.ArrayOps.flatMap(ArrayOps.scala:34)
require("gtools")
require("hash")
# Thunks an expression. Basic lazy evaluation.
thunk <- defmacro(x, expr=function() x)
# But it turns out this is unnecessary! R lazily evaluates its arguments!
thunk2 <- function(x) { function() { x } }
# Further:
delayedAssign("x", 1/0)
# actually is better than what I'd implemented so far: creates a promise for