This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"fmt" | |
"log" | |
"net/http" | |
"os" | |
"os/signal" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func Content(filename string) (string, error) { | |
f, err = os.Open(filename) | |
if err != nil { | |
return nil, err | |
} | |
defer f.Close() | |
var result []byte | |
buf := make([]byte, 100) | |
for { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
var freeList = make(chan *Buffer, 100) | |
var serverChan = make(chan *Buffer) | |
func client() { | |
for { | |
var b *Buffer | |
select { | |
case b = <-freeList: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func gen(nums ...int) chan int { | |
out := make(chan int) | |
go func() { | |
for _, n := range nums { | |
out <- n | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private bool tableExists(string tableName, SQLiteConnection db) | |
{ | |
bool exists; | |
db.Open(); | |
try | |
{ | |
var cmd = new SQLiteCommand( | |
"select case when exists((select * from information_schema.tables where table_name = '" + tableName + "')) then 1 else 0 end", db); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Method 1. with __new__ magic method | |
class Singleton: | |
def __new__(cls): | |
if not hasattr(cls, 'instance'): | |
cls.instance = super().__new__(cls) | |
return cls.instance | |
class TestSingletonNew(Singleton): | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.Video; | |
using UnityEngine.UI; | |
public class testScript : MonoBehaviour { | |
public RawImage image; | |
private VideoPlayer videoPlayer; | |
private VideoSource videoSource; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import json | |
package = sys.argv[1] | |
other_dependencies = set() | |
removing_dependencies = set([package]) | |
for i in json.load(sys.stdin): | |
for p in i['dependencies']: | |
key = p['key'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def max_min(arr): | |
length = len(arr) | |
if length <= 1: | |
return 0 | |
even_length = length | |
last = None | |
if length % 2 == 1: | |
last = arr[length-1] | |
even_length -= 1 | |
i = 0 |
OlderNewer