Skip to content

Instantly share code, notes, and snippets.

{
"response": [
{"title": "Olurum sana", "artists": ["tarkan"], "listen_count": 11},
{"title": "nothing else matters", "artists": ["metallica"], "listen_count": 100},
{"title": "stairway to heaven", "artists": ["led zeppelin"], "listen_count": 90},
{"title": "desert rose", "artists": ["sting", "mahmud fahradi"], "listen_count": 200}
]
}
import json
#import pprint
#pp = pprint.PrettyPrinter(2)
# -----------
f = open("my_collection.json", "r")
contents = f.read()
data = json.loads(contents)
song_list = data['response']
import json
my_songs = [
{
'title': "Olurum sana",
'artists': ["tarkan"]
},
{
'title': "nothing else matters",
'artists': ["metallica"]
from datetime import date
name1 = "kadir"
name2 = "hasan"
name3 = "osman"
x = 3 # int
def get_logged_in_user(app):
if app == "web":
@kadirmalak
kadirmalak / project.clj
Created November 28, 2021 15:36
Minimal OpenGL app Leiningen project file
(defproject lwjgl-demo "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[org.clojure/clojure "1.10.1"]
[org.lwjgl/lwjgl "3.3.0"]
[org.lwjgl/lwjgl "3.3.0" :classifier "natives-macos"]
[org.lwjgl/lwjgl-opengl "3.3.0"]
[org.lwjgl/lwjgl-opengl "3.3.0" :classifier "natives-macos"]
@kadirmalak
kadirmalak / core.clj
Last active November 28, 2021 15:44
Minimal OpenGL example ported from https://www.lwjgl.org/guide
(ns lwjgl-demo.core
(:gen-class)
(:import (org.lwjgl Version)
(org.lwjgl.glfw GLFWErrorCallback GLFW GLFWKeyCallbackI Callbacks)
(org.lwjgl.opengl GL GL33)
(org.lwjgl.system MemoryStack)))
; embedded nREPL
(require '[nrepl.server :refer [start-server stop-server]])
(defonce server (start-server :port 7888))
@kadirmalak
kadirmalak / project.clj
Last active November 28, 2021 15:24
Minimal OpenGL demo dependencies
; you may need to find out the name of the 'classifier' for your native OS
; here I'm on MacOS
[org.lwjgl/lwjgl "3.3.0"]
[org.lwjgl/lwjgl "3.3.0" :classifier "natives-macos"]
[org.lwjgl/lwjgl-opengl "3.3.0"]
[org.lwjgl/lwjgl-opengl "3.3.0" :classifier "natives-macos"]
[org.lwjgl/lwjgl-glfw "3.3.0"]
[org.lwjgl/lwjgl-glfw "3.3.0" :classifier "natives-macos"]
@kadirmalak
kadirmalak / currying-demo-2.scala
Last active December 28, 2019 17:36
currying-demo-2
// notice the visual separation between the group of arguments
def testSomething2(something: String)(var1: Double, var2: String) = {
println(something + ", var1: " + var1 + ", var2: " + var2)
}
// here also the visual separation tells that the first two arguments (the data)
// is something different from the last argument (function to be called with the data)
def runWithVariations2(p1s: List[Int], p2s: List[String])(f: (Double, String) => Unit) = {
for (p1 <- p1s;
p2 <- p2s) {
@kadirmalak
kadirmalak / currying-demo-1.scala
Last active December 28, 2019 16:27
currying-demo-1
// if we do not use currying...
// this is the sample test code
def testSomething(something: String, var1: Double, var2: String) = {
println(something + ", var1: " + var1 + ", var2: " + var2)
}
// this function runs a function with possible variations
def runWithVariations1(v1s: List[Int], v2s: List[String], f: (Double, String) => Unit) = {
for (v1 <- v1s;
@kadirmalak
kadirmalak / currying-3.scala
Created December 28, 2019 16:01
currying in scala nested
def nestedCurrying(a: Int)(b: String)(c: Double) = {
println("a: " + a + ", b: " + b + ", c: " + c)
}
def g1 = nestedCurrying(1) _ // we pass first param
def g2 = g1("str") // and then second param
g2(3.14) // and use it with third param