This file contains hidden or 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
| // Read implements the Conn Read method. | |
| func (c *conn) Read(b []byte) (int, error) { | |
| if !c.ok() { | |
| return 0, syscall.EINVAL | |
| } | |
| n, err := c.fd.Read(b) | |
| if err != nil && err != io.EOF { | |
| err = &OpError{Op: "read", | |
| Net: c.fd.net, | |
| Source: c.fd.laddr, |
This file contains hidden or 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
| // Conn is a generic stream-oriented network connection. | |
| // Comments truncated for brevity | |
| type Conn interface { | |
| Read(b []byte) (n int, err error) | |
| Write(b []byte) (n int, err error) | |
| Close() error | |
| LocalAddr() Addr | |
| RemoteAddr() Addr | |
| SetDeadline(t time.Time) error |
This file contains hidden or 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
| // Network file descriptor. | |
| type netFD struct { | |
| pfd poll.FD | |
| // immutable until Close | |
| family int | |
| sotype int | |
| isConnected bool // handshake completed or use of association with peer | |
| net string | |
| laddr Addr |
This file contains hidden or 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 ( | |
| "log" | |
| "syscall" | |
| ) | |
| func main() { | |
| //Open File to Retrieve Handler | |
| fd, err := syscall.Open("<absolute-path-to-file>", syscall.O_RDWR, 755) |
This file contains hidden or 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
| // Code Snippet 1 | |
| // os/file_windows.go | |
| func openFile(name string, flag int, perm FileMode) (file *File, err error) { | |
| r, e := syscall.Open(fixLongPath(name), flag|syscall.O_CLOEXEC, syscallMode(perm)) | |
| if e != nil { | |
| return nil, e | |
| } | |
| return newFile(r, name, "file"), nil | |
| } |
This file contains hidden or 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
| #OMBMAR001 | |
| .data | |
| isPalinMess: .asciiz "It is a palindrome \n" | |
| noPalinMess: .asciiz "It is not a palindrome \n" | |
| startMess: .asciiz "Enter a number: \n" | |
| temp1: .word 0 # entered number | |
| decima: .word 10 #decima | |
| .text |
This file contains hidden or 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 CreateGCEInstance() { | |
| //STEP 1 - INIT DATA - Add all your initialization data e.g. projectid, zones, accessTokens. | |
| project := "<your-project-here>" | |
| zone := "<your-zone-here>" //e.g. europe-west1-d | |
| accessToken := "" ////retrieve from https://developers.google.com/oauthplayground/ select relevant compute engine scopes e.g. devstorage/read_write and auth/compute | |
| endpoint := fmt.Sprintf("https://www.googleapis.com/compute/v1/projects/%s/zones/%s/instances", project, zone) | |
| //STEP 2 - REQUEST BODY | |
| //Create a REST representation of whats required. see https://cloud.google.com/compute/docs/reference/rest/v1/instances/insert | |
| reqBody := struct { |
This file contains hidden or 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 ( | |
| "net/http" | |
| "fmt" | |
| "time" | |
| "html/template" | |
| ) | |
| //Create a struct that holds information to be displayed in our HTML file | |
| type Welcome struct { |
This file contains hidden or 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 java.io.*; | |
| import java.net.ServerSocket; | |
| import java.net.Socket; | |
| import java.util.Scanner; | |
| /** | |
| * Written by Martin Ombura Jr. <@martinomburajr> | |
| */ | |
| public class MyServer { | |
| public static void main(String[] args) { |
This file contains hidden or 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 java.io.*; | |
| import java.net.ServerSocket; | |
| import java.net.Socket; | |
| import java.util.Scanner; | |
| /** | |
| * Written by Martin Ombura Jr. <@martinomburajr> | |
| */ | |
| public class MyServer { | |
| public static void main(String[] args) { |