text:
Q: Extract repository name from GitHub url in bash Given ANY GitHub repository url string like:
git://github.com/some-user/my-repo.git

or
git@github.com:some-user/my-repo.git

or
https://github.com/some-user/my-repo.git

What is the best way in bash to extract the repository name my-repo from any of the following strings? The solution MUST work for all types of urls specified above.
Thanks.

A: Summing up:

*

*Get url without (optional) suffix:
url_without_suffix="${url%.*}"

*Get repository name:
reponame="$(basename "${url_without_suffix}")"

*Get user (host) name afterwards:
hostname="$(basename "${url_without_suffix%/${reponame}}")"

A: $ url=git://github.com/some-user/my-repo.git
$ basename=$(basename $url)
$ echo $basename
my-repo.git
$ filename=${basename%.*}
$ echo $filename
my-repo
$ extension=${basename##*.}
$ echo $extension
git

A: I'd go with basename $URL .git.

A: Old post, but I faced the same problem recently.
The regex ^(https|git)(:\/\/|@)([^\/:]+)[\/:]([^\/:]+)\/(.+).git$ works for the three types of URL.
#!/bin/bash

# url="git://github.com/some-user/my-repo.git"
# url="https://github.com/some-user/my-repo.git"
url="git@github.com:some-user/my-repo.git"

re="^(https|git)(:\/\/|@)([^\/:]+)[\/:]([^\/:]+)\/(.+)(.git)*$"

if [[ $url =~ $re ]]; then
    protocol=${BASH_REMATCH[1]}
    separator=${BASH_REMATCH[2]}
    hostname=${BASH_REMATCH[3]}
    user=${BASH_REMATCH[4]}
    repo=${BASH_REMATCH[5]}
fi

Explaination (see it in action on regex101):

*

*^ matches the start of a string

*(https|git) matches and captures the characters https or git

*(:\/\/|@) matches and captures the characters :// or @

*([^\/:]+) matches and captures one character or more that is not / nor :

*[\/:] matches one character that is / or :

*([^\/:]+) matches and captures one character or more that is not / nor :, yet again

*[\/:] matches the character /

*(.+) matches and captures one character or more

*(.git)* matches optional .git suffix at the end

*$ matches the end of a string

This if far from perfect, as something like https@github.com:some-user/my-repo.git would match, but I think it's fine enough for extraction.

A: use regular expression: /([^/]+)\.git$/

A: basename $git_repo_url | tr -d ".git"

A: basename is my favorite, but you can also use sed:
url=git://github.com/some-user/my-repo.git
reponame="$(echo $url | sed -r 's/.+\/([^.]+)(\.git)?/\1/')"
# reponame = "my-repo"

"sed" will delete all text until the last / + the .git extension (if exists), and will retain the match of group \1 which is everything except dot ([^.]+)

A: Using Hitcham's awesome answer above allowed me to come up with this, using sed to output exactly what needed: org/reponame with sed.
output = echo ${git_url} | sed -nr  's/^(https|git)(:\/\/|@)([^\/:]+)[\/:]([^\/:]+)\/(.+).git$$/\4\/\3/p'`

Works well in ubuntu, doesn't work for the sed available by default on macosx.

A: A slight modification to @Hicham's answer
^(https|git)(:\/\/|@)([^\/:]+)[\/:]([^\/:]+)\/(.+?)(\.git)?$
Will extract out the .git suffix as well.


text:
Q: Google Calendar API Time When I try to format 2015-05-29T19:30:00+08:00 from google calendar api;
return \Carbon\Carbon::createFromTimeStamp(
        strtotime('2015-05-29T19:30:00+08:00')
        );

I get the result 2015-05-29 11:30:00
But the start date of the event in my google calendar is exactly 07:30PM
One thing is that if I try to add a ->diffForHumans(); I get the result:
16 minutes ago (Note: the time I run the code is 7:46PM)
Can you help me to understand what is going on in here.

A: Instead of converting the datetime to a unix timestamp, try directly creating a DateTime instance using the original date format which is ISO8601, this should automatically take into account the timezone
return Carbon::createFromFormat(Carbon::ISO8601, '2015-05-29T19:30:00+08:00');

redpajama_set_name: RedPajamaStackExchange


text:
Q: Force EF to save specified decimal places I defined some decimal properties in my entities:
public class Entity1
{
   public int Id { get; set; }

   public decimal Value {get; set;}
}

and because I want to save maximum 4 decimal places for my decimals, in my configuration files I defined:
this.Property(t => t.Value).HasPrecision(18, 4);

so the result is Value field with 4 decimal places in my Entity1 table.
How can I force EF to save only decimal places that used in Value's value?
for example:

*

*if Value = 0.05 then it save 0.05 and when I read the Value from Db it shows me 0.05 and not 0.0500

*if Value = 0.050 then it save 0.050

*if Value = 0.05000 then it save 0.0500 (because maximum decimal places is 4)

In the other word, I want to EF save decimal places that end user specified in Value.

A: Since your concern is about display the numbers the way they were entered and not as much with preserving the exact precision for mathematical reasons, you have a couple of options.
I am assuming that you actually need the value to be numeric within the database, for querying or calculation purposes.  Otherwise, you could save it as a string.
You could save a second value, representing the precision of the entered value, and use that to create a format string for your value:
public decimal  Value { get; set; }
public byte     ValuePrecision { get; set; }

public string FormatValue()
{
    string fmtString = string.Format("{{0:N{0}}}", this.ValuePrecision);
    return string.Format(fmtString, this.Value);
}

DISCLAIMER:  code was done from memory and has not been tested.


text:
Q: magento 2.3.5 image cache being auto generated Images inside cache folder are being auto generated
I've truncate 3 specific folder that I know we don't need it after while checking again it has generated all over again when there hasn't been image resize called.
E.G:
root@jv-webdb-01 cache]# ls -la bb6cd3821999ba83509fb2097677c3f7
total 8
drwxrwxr-x  2 jv.com jv.com 4096 Jul  8 16:47 .
drwxrwxr-x 68 jv.com jv.com 4096 Jul  8 18:08 ..
[root@jv-webdb-01 cache]# ls -la bb6cd3821999ba83509fb2097677c3f7
total 40
drwxrwxr-x 10 jv.com jv.com 4096 Jul  8 18:19 .
drwxrwxr-x 68 jv.com jv.com 4096 Jul  8 18:08 ..
drwxrwxr-x  3 jv.com jv.com 4096 Jul  8 18:19 b
drwxrwxr-x  3 jv.com jv.com 4096 Jul  8 18:19 B
drwxrwxr-x  3 jv.com jv.com 4096 Jul  8 18:15 h
drwxrwxr-x  3 jv.com jv.com 4096 Jul  8 18:17 l
drwxrwxr-x  3 jv.com jv.com 4096 Jul  8 18:14 m
drwxrwxr-x  3 jv.com jv.com 4096 Jul  8 18:14 v
drwxrwxr-x  4 jv.com jv.com 4096 Jul  8 18:14 w
drwxrwxr-x  3 jv.com jv.com 4096 Jul  8 18:14 W
[root@jv-webdb-01 cache]#

Anyone any idea?
Thanks

A: I found that images in /cache/folder is auto generated on demand if they aren't cached and get request the re-generated from the original if exists and according to the sizes for specific settings, but it can be confusing as to which cache folder is for which sizes, E.G: small, thumbnail, base etc...
Where could I find this dynamic created folder, is in DB table ?
Thanks

A: When you run storefront at that time cache folder's images auto generated.
It's magento's behavior for page speed purpose.
what's you are looking for exactly??


text:
Q: Editable spreadsheet control in a webpage I am trying to place an editable spreadsheet control in a webpage without the menus and toolbars.  I saw the postings about this and the last one said to use Google Docs spreadsheet and then choose Publish.  If you use "?widget=true&headers=false" then the menus and toolbars will be removed.
This works great.  The only problem is the data is not editable!  It's a static spreadsheet.  Is there a way to get the google spreadsheet control in a web page without menus and toolbars but make it editable?

A: I simply put the spreadsheet control inside a div and used the div to cover up the tool bars and scroll bars, etc.  Worked great.
Here is the html:


text:
Q: Android Emulator Crashes on Windows 10 with HAXM 7.8.0 I am running into an issue where I cannot run the Android emulator with seemingly any version of HAXM installed, including the latest version 7.8.0.  Below is the emulator log output using the verbose and show-kernal options.
Windows 10 build 19044.2364
openjdk version "11.0.12" 2021-07-20
INFO    | Android emulator version 31.3.14.0 (build_id 9322596) (CL:N/A)
INFO    | Found AVD name 'pixel_5_-_api_30'
INFO    | Found AVD target architecture: x86
INFO    | argv[0]: 'emulator'; program directory: 'C:\Program Files (x86)\Android\android-sdk\emulator'
VERBOSE |  Found directory: C:\Program Files (x86)\Android\android-sdk\system-images\android-30\google_apis\x86\
emulator: INFO: Found systemPath C:\Program Files (x86)\Android\android-sdk\system-images\android-30\google_apis\x86\
INFO    | emuDirName: 'C:\Program Files (x86)\Android\android-sdk\emulator'
VERBOSE |  Found directory: C:\Program Files (x86)\Android\android-sdk\system-images\android-30\google_apis\x86\
emulator: INFO: Found systemPath C:\Program Files (x86)\Android\android-sdk\system-images\android-30\google_apis\x86\
INFO    | Probing for C:\Program Files (x86)\Android\android-sdk\system-images\android-30\google_apis\x86\\kernel-ranchu-64: file exists
INFO    | try dir C:\Program Files (x86)\Android\android-sdk\emulator
INFO    | Trying emulator path 'C:\Program Files (x86)\Android\android-sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe'
INFO    | Found target-specific 64-bit emulator binary: C:\Program Files (x86)\Android\android-sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe
INFO    | Adding library search path: 'C:\Program Files (x86)\Android\android-sdk\emulator\lib64'
INFO    | Adding library search path: 'C:\Program Files (x86)\Android\android-sdk\emulator\lib64\gles_swiftshader'
VERBOSE | Adding library search path for Qt: 'C:\Program Files (x86)\Android\android-sdk\emulator\lib64\qt\lib'
VERBOSE | Silencing all qWarning(); use qCWarning(...) instead: QT_LOGGING_RULES=default.warning=false
VERBOSE | Setting Qt plugin search path: QT_QPA_PLATFORM_PLUGIN_PATH=C:\Program Files (x86)\Android\android-sdk\emulator\lib64\qt\plugins
VERBOSE | Setting Qt to use software OpenGL: QT_OPENGL=software
VERBOSE | Setting QML to use software QtQuick2D: QMLSCENE_DEVICE=softwarecontext
VERBOSE | Overriding pre-existing bad Qt high dpi settings...
INFO    | Quoted param: ["C:\Program Files (x86)\Android\android-sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe"]
INFO    | Quoted param: [-avd]
INFO    | Quoted param: [pixel_5_-_api_30]
INFO    | Quoted param: [-verbose]
INFO    | Quoted param: [-show-kernel]
VERBOSE | emulator: Running :C:\Program Files (x86)\Android\android-sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe
VERBOSE | qemu backend: argv[00] = ""C:\Program Files (x86)\Android\android-sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe""
VERBOSE | qemu backend: argv[01] = "-avd"
VERBOSE | qemu backend: argv[02] = "pixel_5_-_api_30"
VERBOSE | qemu backend: argv[03] = "-verbose"
VERBOSE | qemu backend: argv[04] = "-show-kernel"
VERBOSE | Concatenated backend parameters:  '"C:\Program Files (x86)\Android\android-sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe" ' -avd pixel_5_-_api_30 -verbose -show-kernel
INFO    | Duplicate loglines will be removed, if you wish to see each indiviudal line launch with the -log-nofilter flag.
VERBOSE | autoconfig: -skin 1080x2340
VERBOSE | autoconfig: -skindir (null)
WARNING | unexpected system image feature string, emulator might not function correctly, please try updating the emulator.
VERBOSE | Unexpected feature list:
VERBOSE | Vulkan
VERBOSE | querying file version info API...
VERBOSE | found kernelbase.dll
VERBOSE | GetFileVersionInfoSizeW found. On Windows 10?
VERBOSE | GetFileVersionInfoW found. On Windows 10?
VERBOSE | VerQueryValueW found. Can query file versions
VERBOSE | queryFileVersionInfo: path not found: amdvlk64.dll
VERBOSE | querying file version info API...
VERBOSE | queryFileVersionInfo: path not found: amdvlk32.dll
VERBOSE | querying file version info API...
VERBOSE | autoconfig: -kernel C:\Program Files (x86)\Android\android-sdk\system-images\android-30\google_apis\x86\\kernel-ranchu-64
VERBOSE | Target arch = 'x86'
VERBOSE | Auto-config: -qemu -cpu qemu32
VERBOSE | Auto-detect: Kernel image requires new device naming scheme.
VERBOSE | Auto-detect: Kernel does not support YAFFS2 partitions.
VERBOSE | autoconfig: -ramdisk C:\Program Files (x86)\Android\android-sdk\system-images\android-30\google_apis\x86\\ramdisk.img
VERBOSE | Using initial system image: C:\Program Files (x86)\Android\android-sdk\system-images\android-30\google_apis\x86\\system.img
VERBOSE | Using initial vendor image: C:\Program Files (x86)\Android\android-sdk\system-images\android-30\google_apis\x86\\vendor.img
VERBOSE | autoconfig: -initdata C:\Program Files (x86)\Android\android-sdk\system-images\android-30\google_apis\x86\\userdata.img
VERBOSE | autoconfig: -cache C:\Users\username\.android\avd\pixel_5_-_api_30.avd\cache.img
VERBOSE | autoconfig: -sdcard C:\Users\username\.android\avd\pixel_5_-_api_30.avd\sdcard.img
VERBOSE | Increasing RAM size to 2048MB
VERBOSE | VM heap size 256MB is below hardware specified minimum of 512MB,setting it to that value
VERBOSE | System image is read only
INFO    | IPv4 server found: **REDACTED**
VERBOSE | Found 1 DNS servers:
VERBOSE |       **REDACTED**
VERBOSE | found magic skin width=1080 height=2340 bpp=16

VERBOSE | Creating ext4 userdata partition: C:\Users\username\.android\avd\pixel_5_-_api_30.avd\data
Creating filesystem with parameters:
    Size: 6442450944
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 8192
    Inode size: 256
    Journal blocks: 24576
    Label:
    Blocks: 1572864
    Block groups: 48
    Reserved block group size: 383
Created filesystem with 24/393216 inodes and 52345/1572864 blocks
VERBOSE | CPU Acceleration: working
VERBOSE | CPU Acceleration status: HAXM version 7.8.0 (4) is installed and usable.
VERBOSE | handleCpuAcceleration: feature check for hvf
VERBOSE | registered 'boot-properties' qemud service
VERBOSE | Adding boot property: 'qemu.cmdline' = 'androidboot.logcat=*:V androidboot.consolepipe=qemu_pipe,pipe:logcat'
VERBOSE | Adding boot property: 'qemu.logcat' = 'start'
VERBOSE | GPU emulation enabled using 'swiftshader_indirect' mode
VERBOSE | Initializing hardware OpenGLES emulation support
VERBOSE | create display 0
VERBOSE | setDisplayPose 0 x 0 y 0 w 1080 h 2340 dpi 0
INFO    | added library vulkan-1.dll
ERROR   | Failed to create Vulkan instance.
INFO    | configAndStartRenderer: setting vsync to 60 hz
VERBOSE | Found 1 DNS servers:
VERBOSE |      **REDACTED**
INFO    | Content of hardware configuration file:
INFO    |       hw.cpu.arch = x86
INFO    |       hw.cpu.model = qemu32
INFO    |       hw.cpu.ncore = 4
INFO    |       hw.ramSize = 2048
INFO    |       hw.screen = multi-touch
INFO    |       hw.mainKeys = false
INFO    |       hw.trackBall = false
INFO    |       hw.keyboard = true
INFO    |       hw.keyboard.lid = false
INFO    |       hw.keyboard.charmap = qwerty2
INFO    |       hw.dPad = false
INFO    |       hw.rotaryInput = false
INFO    |       hw.gsmModem = true
INFO    |       hw.gps = true
INFO    |       hw.battery = true
INFO    |       hw.accelerometer = true
INFO    |       hw.gyroscope = true
INFO    |       hw.audioInput = true
INFO    |       hw.audioOutput = true
INFO    |       hw.sdCard = true
INFO    |       hw.sdCard.path = C:\Users\username\.android\avd\pixel_5_-_api_30.avd\sdcard.img
INFO    |       disk.cachePartition = true
INFO    |       disk.cachePartition.path = C:\Users\username\.android\avd\pixel_5_-_api_30.avd\cache.img
INFO    |       disk.cachePartition.size = 66m
INFO    |       test.quitAfterBootTimeOut = -1
INFO    |       test.delayAdbTillBootComplete = 0
INFO    |       test.monitorAdb = 0
INFO    |       hw.lcd.width = 1080
INFO    |       hw.lcd.height = 2340
INFO    |       hw.lcd.depth = 16
INFO    |       hw.lcd.density = 440
INFO    |       hw.lcd.backlight = true
INFO    |       hw.lcd.vsync = 60
INFO    |       hw.gltransport = pipe
INFO    |       hw.gltransport.asg.writeBufferSize = 1048576
INFO    |       hw.gltransport.asg.writeStepSize = 4096
INFO    |       hw.gltransport.asg.dataRingSize = 32768
INFO    |       hw.gltransport.drawFlushInterval = 800
INFO    |       hw.displayRegion.0.1.xOffset = -1
INFO    |       hw.displayRegion.0.1.yOffset = -1
INFO    |       hw.displayRegion.0.1.width = 0
INFO    |       hw.displayRegion.0.1.height = 0
INFO    |       hw.displayRegion.0.2.xOffset = -1
INFO    |       hw.displayRegion.0.2.yOffset = -1
INFO    |       hw.displayRegion.0.2.width = 0
INFO    |       hw.displayRegion.0.2.height = 0
INFO    |       hw.displayRegion.0.3.xOffset = -1
INFO    |       hw.displayRegion.0.3.yOffset = -1
INFO    |       hw.displayRegion.0.3.width = 0
INFO    |       hw.displayRegion.0.3.height = 0
INFO    |       hw.display1.width = 0
INFO    |       hw.display1.height = 0
INFO    |       hw.display1.density = 0
INFO    |       hw.display1.xOffset = -1
INFO    |       hw.display1.yOffset = -1
INFO    |       hw.display1.flag = 0
INFO    |       hw.display2.width = 0
INFO    |       hw.display2.height = 0
INFO    |       hw.display2.density = 0
INFO    |       hw.display2.xOffset = -1
INFO    |       hw.display2.yOffset = -1
INFO    |       hw.display2.flag = 0
INFO    |       hw.display3.width = 0
INFO    |       hw.display3.height = 0
INFO    |       hw.display3.density = 0
INFO    |       hw.display3.xOffset = -1
INFO    |       hw.display3.yOffset = -1
INFO    |       hw.display3.flag = 0
INFO    |       hw.multi_display_window = false
INFO    |       hw.gpu.enabled = true
INFO    |       hw.gpu.mode = swiftshader_indirect
INFO    |       hw.initialOrientation = portrait
INFO    |       hw.camera.back = virtualscene
INFO    |       hw.camera.front = emulated
INFO    |       vm.heapSize = 512
INFO    |       hw.sensors.light = true
INFO    |       hw.sensors.pressure = true
INFO    |       hw.sensors.humidity = true
INFO    |       hw.sensors.proximity = true
INFO    |       hw.sensors.magnetic_field = true
INFO    |       hw.sensors.magnetic_field_uncalibrated = true
INFO    |       hw.sensors.gyroscope_uncalibrated = true
INFO    |       hw.sensors.orientation = true
INFO    |       hw.sensors.temperature = true
INFO    |       hw.sensors.rgbclight = false
INFO    |       hw.sensor.hinge = false
INFO    |       hw.sensor.hinge.count = 0
INFO    |       hw.sensor.hinge.type = 0
INFO    |       hw.sensor.hinge.sub_type = 0
INFO    |       hw.sensor.hinge.fold_to_displayRegion.0.1_at_posture = 1
INFO    |       hw.sensor.roll = false
INFO    |       hw.sensor.roll.count = 0
INFO    |       hw.sensor.roll.resize_to_displayRegion.0.1_at_posture = 6
INFO    |       hw.sensor.roll.resize_to_displayRegion.0.2_at_posture = 6
INFO    |       hw.sensor.roll.resize_to_displayRegion.0.3_at_posture = 6
INFO    |       hw.sensors.heart_rate = false
INFO    |       hw.sensors.wrist_tilt = false
INFO    |       hw.useext4 = true
INFO    |       hw.arc = false
INFO    |       hw.arc.autologin = false
INFO    |       hw.device.name = pixel_5
INFO    |       kernel.path = C:\Program Files (x86)\Android\android-sdk\system-images\android-30\google_apis\x86\\kernel-ranchu-64
INFO    |       kernel.newDeviceNaming = yes
INFO    |       kernel.supportsYaffs2 = no
INFO    |       disk.ramdisk.path = C:\Program Files (x86)\Android\android-sdk\system-images\android-30\google_apis\x86\\ramdisk.img
INFO    |       disk.systemPartition.initPath = C:\Program Files (x86)\Android\android-sdk\system-images\android-30\google_apis\x86\\system.img
INFO    |       disk.systemPartition.size = 3083m
INFO    |       disk.vendorPartition.initPath = C:\Program Files (x86)\Android\android-sdk\system-images\android-30\google_apis\x86\\vendor.img
INFO    |       disk.vendorPartition.size = 800m
INFO    |       disk.dataPartition.path = C:\Users\username\.android\avd\pixel_5_-_api_30.avd\userdata-qemu.img
INFO    |       disk.dataPartition.initPath = C:\Program Files (x86)\Android\android-sdk\system-images\android-30\google_apis\x86\\userdata.img
INFO    |       disk.dataPartition.size = 6g
INFO    |       disk.encryptionKeyPartition.path = C:\Users\username\.android\avd\pixel_5_-_api_30.avd\encryptionkey.img
INFO    |       PlayStore.enabled = false
INFO    |       avd.name = pixel_5_-_api_30
INFO    |       avd.id = pixel_5_-_api_30
INFO    |       fastboot.forceColdBoot = false
INFO    |       android.sdk.root = C:\Program Files (x86)\Android\android-sdk
INFO    |       android.avd.home = C:\Users\username\.android\avd
INFO    | .
INFO    | QEMU options list:
INFO    |        argv[00] = "C:\Program Files (x86)\Android\android-sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe"
INFO    |        argv[01] = "-dns-server"
INFO    |        argv[02] = "**REDACTED**"
INFO    |        argv[03] = "-mem-path"
INFO    |        argv[04] = "C:\Users\username\.android\avd\pixel_5_-_api_30.avd\snapshots\default_boot\ram.img"
INFO    |        argv[05] = "-mem-file-shared"
INFO    |        argv[06] = "-serial"
INFO    |        argv[07] = "con:"
INFO    |        argv[08] = "-device"
INFO    |        argv[09] = "goldfish_pstore,addr=0xff018000,size=0x10000,file=C:\Users\username\.android\avd\pixel_5_-_api_30.avd\data\misc\pstore\pstore.bin"
INFO    |        argv[10] = "-cpu"
INFO    |        argv[11] = "android64"
INFO    |        argv[12] = "-enable-hax"
INFO    |        argv[13] = "-smp"
INFO    |        argv[14] = "cores=4"
INFO    |        argv[15] = "-m"
INFO    |        argv[16] = "2048"
INFO    |        argv[17] = "-lcd-density"
INFO    |        argv[18] = "440"
INFO    |        argv[19] = "-nodefaults"
INFO    |        argv[20] = "-kernel"
INFO    |        argv[21] = "C:\Program Files (x86)\Android\android-sdk\system-images\android-30\google_apis\x86\\kernel-ranchu-64"
INFO    |        argv[22] = "-initrd"
INFO    |        argv[23] = "C:\Program Files (x86)\Android\android-sdk\system-images\android-30\google_apis\x86\\ramdisk.img"
INFO    |        argv[24] = "-drive"
INFO    |        argv[25] = "if=none,index=0,id=system,if=none,file=C:\Program Files (x86)\Android\android-sdk\system-images\android-30\google_apis\x86\\system.img,read-only"
INFO    |        argv[26] = "-device"
INFO    |        argv[27] = "virtio-blk-pci,drive=system,modern-pio-notify"
INFO    |        argv[28] = "-drive"
INFO    |        argv[29] = "if=none,index=1,id=cache,if=none,file=C:\Users\username\.android\avd\pixel_5_-_api_30.avd\cache.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576"
INFO    |        argv[30] = "-device"
INFO    |        argv[31] = "virtio-blk-pci,drive=cache,modern-pio-notify"
INFO    |        argv[32] = "-drive"
INFO    |        argv[33] = "if=none,index=2,id=userdata,if=none,file=C:\Users\username\.android\avd\pixel_5_-_api_30.avd\userdata-qemu.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576"
INFO    |        argv[34] = "-device"
INFO    |        argv[35] = "virtio-blk-pci,drive=userdata,modern-pio-notify"
INFO    |        argv[36] = "-drive"
INFO    |        argv[37] = "if=none,index=3,id=encrypt,if=none,file=C:\Users\username\.android\avd\pixel_5_-_api_30.avd\encryptionkey.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576"
INFO    |        argv[38] = "-device"
INFO    |        argv[39] = "virtio-blk-pci,drive=encrypt,modern-pio-notify"
INFO    |        argv[40] = "-drive"
INFO    |        argv[41] = "if=none,index=4,id=vendor,if=none,file=C:\Program Files (x86)\Android\android-sdk\system-images\android-30\google_apis\x86\\vendor.img,read-only"
INFO    |        argv[42] = "-device"
INFO    |        argv[43] = "virtio-blk-pci,drive=vendor,modern-pio-notify"
INFO    |        argv[44] = "-drive"
INFO    |        argv[45] = "if=none,index=5,id=sdcard,if=none,file=C:\Users\username\.android\avd\pixel_5_-_api_30.avd\sdcard.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576"
INFO    |        argv[46] = "-device"
INFO    |        argv[47] = "virtio-blk-pci,drive=sdcard,modern-pio-notify"
INFO    |        argv[48] = "-netdev"
INFO    |        argv[49] = "user,id=mynet"
INFO    |        argv[50] = "-device"
INFO    |        argv[51] = "virtio-net-pci,netdev=mynet"
INFO    |        argv[52] = "-device"
INFO    |        argv[53] = "virtio-rng-pci"
INFO    |        argv[54] = "-show-cursor"
INFO    |        argv[55] = "-device"
INFO    |        argv[56] = "virtio_input_multi_touch_pci_1"
INFO    |        argv[57] = "-device"
INFO    |        argv[58] = "virtio_input_multi_touch_pci_2"
INFO    |        argv[59] = "-device"
INFO    |        argv[60] = "virtio_input_multi_touch_pci_3"
INFO    |        argv[61] = "-device"
INFO    |        argv[62] = "virtio_input_multi_touch_pci_4"
INFO    |        argv[63] = "-device"
INFO    |        argv[64] = "virtio_input_multi_touch_pci_5"
INFO    |        argv[65] = "-device"
INFO    |        argv[66] = "virtio_input_multi_touch_pci_6"
INFO    |        argv[67] = "-device"
INFO    |        argv[68] = "virtio_input_multi_touch_pci_7"
INFO    |        argv[69] = "-device"
INFO    |        argv[70] = "virtio_input_multi_touch_pci_8"
INFO    |        argv[71] = "-device"
INFO    |        argv[72] = "virtio_input_multi_touch_pci_9"
INFO    |        argv[73] = "-device"
INFO    |        argv[74] = "virtio_input_multi_touch_pci_10"
INFO    |        argv[75] = "-device"
INFO    |        argv[76] = "virtio_input_multi_touch_pci_11"
INFO    |        argv[77] = "-device"
INFO    |        argv[78] = "virtio-keyboard-pci"
INFO    |        argv[79] = "-L"
INFO    |        argv[80] = "C:\Program Files (x86)\Android\android-sdk\emulator/lib/pc-bios"
INFO    |        argv[81] = "-soundhw"
INFO    |        argv[82] = "hda"
INFO    |        argv[83] = "-vga"
INFO    |        argv[84] = "none"
INFO    |        argv[85] = "-append"
INFO    |        argv[86] = "no_timer_check clocksource=pit console=ttyS0,38400 cma=296M@0-4G mac80211_hwsim.channels=2 loop.max_part=7 ramoops.mem_address=0xff018000 ramoops.mem_size=0x10000 memmap=0x10000$0xff018000 printk.devkmsg=on qemu=1 androidboot.hardware=ranchu androidboot.serialno=EMULATOR31X3X14X0 qemu.gles=1 qemu.settings.system.screen_off_timeout=2147483647 qemu.encrypt=1 qemu.vsync=60 qemu.gltransport=pipe qemu.gltransport.drawFlushInterval=800 qemu.opengles.version=196608 qemu.uirenderer=skiagl qemu.dalvik.vm.heapsize=512m qemu.camera_protocol_ver=1 qemu.camera_hq_edge_processing=0 androidboot.vbmeta.size=6144 androidboot.vbmeta.hash_alg=sha256 androidboot.vbmeta.digest=ea5843921b6671f2d851ebf15e7b55f71e73fc36967778bca3be3e3cf4e15f28 androidboot.boot_devices=pci0000:00/0000:00:03.0 qemu.wifi=1 qemu.hwcodec.avcdec=2 qemu.hwcodec.vpxdec=2 android.qemud=1 qemu.avd_name=pixel_5_-_api_30"
INFO    |        argv[87] = "-android-hw"
INFO    |        argv[88] = "C:\Users\username\.android\avd\pixel_5_-_api_30.avd\hardware-qemu.ini"
INFO    | Concatenated QEMU options: "C:\Program Files (x86)\Android\android-sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe" -dns-server 10.10.10.228 -mem-path C:\Users\username\.android\avd\pixel_5_-_api_30.avd\snapshots\default_boot\ram.img -mem-file-shared -serial con: -device goldfish_pstore,addr=0xff018000,size=0x10000,file=C:\Users\username\.android\avd\pixel_5_-_api_30.avd\data\misc\pstore\pstore.bin -cpu android64 -enable-hax -smp cores=4 -m 2048 -lcd-density 440 -nodefaults -kernel "C:\Program Files (x86)\Android\android-sdk\system-images\android-30\google_apis\x86\\kernel-ranchu-64" -initrd "C:\Program Files (x86)\Android\android-sdk\system-images\android-30\google_apis\x86\\ramdisk.img" -drive "if=none,index=0,id=system,if=none,file=C:\Program Files (x86)\Android\android-sdk\system-images\android-30\google_apis\x86\\system.img,read-only" -device virtio-blk-pci,drive=system,modern-pio-notify -drive if=none,index=1,id=cache,if=none,file=C:\Users\username\.android\avd\pixel_5_-_api_30.avd\cache.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576 -device virtio-blk-pci,drive=cache,modern-pio-notify -drive if=none,index=2,id=userdata,if=none,file=C:\Users\username\.android\avd\pixel_5_-_api_30.avd\userdata-qemu.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576 -device virtio-blk-pci,drive=userdata,modern-pio-notify -drive if=none,index=3,id=encrypt,if=none,file=C:\Users\username\.android\avd\pixel_5_-_api_30.avd\encryptionkey.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576 -device virtio-blk-pci,drive=encrypt,modern-pio-notify -drive "if=none,index=4,id=vendor,if=none,file=C:\Program Files (x86)\Android\android-sdk\system-images\android-30\google_apis\x86\\vendor.img,read-only" -device virtio-blk-pci,drive=vendor,modern-pio-notify -drive if=none,index=5,id=sdcard,if=none,file=C:\Users\username\.android\avd\pixel_5_-_api_30.avd\sdcard.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576 -device virtio-blk-pci,drive=sdcard,modern-pio-notify -netde
VERBOSE | Android qemu version 31.3.14.0 (build_id 9322596) (CL:N/A)
VERBOSE | Starting QEMU main loop
VERBOSE | android_fopen: Failed to open /qemu.conf, err: 2
VERBOSE | Adding boot property: 'ro.opengles.version' = '196608'
VERBOSE | Adding boot property: 'qemu.sf.fake_camera' = 'front'
VERBOSE | Adding boot property: 'qemu.adb.secure' = '1'
VERBOSE | Adding boot property: 'dalvik.vm.heapsize' = '512m'
VERBOSE | Adding boot property: 'qemu.hw.mainkeys' = '0'
VERBOSE | Adding boot property: 'qemu.sf.lcd_density' = '440'
HAX is working and emulator runs in fast virt mode.
VERBOSE | control console listening on port 5554, ADB on port 5555
VERBOSE | goldfish_events.have-dpad: false
VERBOSE | goldfish_events.have-trackball: false
VERBOSE | goldfish_events.have-camera: true
VERBOSE | goldfish_events.have-keyboard: false
VERBOSE | goldfish_events.have-lidswitch: false
VERBOSE | goldfish_events.have-tabletmode: false
VERBOSE | goldfish_events.have-touch: false
VERBOSE | goldfish_events.have-multitouch: false
VERBOSE | Adding boot property: 'net.wifi_mac_prefix' = '5554'
dsound: Could not initialize DirectSoundCapture
dsound: Reason: No sound driver is available for use, or the given GUID is not a valid DirectSound device ID
VERBOSE | Not using any http proxy
VERBOSE | Adding boot property: 'qemu.timezone' = 'America/New_York'
VERBOSE | android_hw_fingerprint_init: fingerprint qemud listen service initialized
WARNING | *** No gRPC protection active, consider launching with the -grpc-use-jwt flag.***
INFO    | Started GRPC server at 127.0.0.1:8554, security: Local, auth: none
INFO    | Advertising in: C:\Users\username\AppData\Local\Temp\avd\running\pid_7716.ini
Attempt to initialize voice without DirectSoundCapture object
Attempt to initialize voice without DirectSoundCapture object
Failed to create voice `adc'
Failed to sync vcpu reg
Failed to sync vcpu reg
Failed to sync vcpu reg
Failed to sync vcpu reg
Failed to sync vcpu reg
VERBOSE | emulator_window_fb_rotate
INFO    | setDisplayConfigs w 1080 h 2340 dpiX 440 dpiY 440
VERBOSE | config multidisplay with config.ini 0x0 0x0 0x0
VERBOSE | No acpi ini file provided, using default
Failed to sync vcpu reg
Failed to sync vcpu reg
Failed to sync vcpu reg
Failed to sync vcpu reg
Failed to sync vcpu reg
Failed to sync vcpu reg
Failed to sync vcpu reg
Failed to sync vcpu reg
Failed to sync vcpu reg
Failed to sync vcpu reg
VCPU shutdown request
VERBOSE | Saving state on exit with session uptime 202 ms
VCPU shutdown request
VERBOSE |  no root specified:
VERBOSE | Path:C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe protocol version: 41
VERBOSE | Found: 1 adb executables
VERBOSE | Adb: C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe
VERBOSE | Path:C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe protocol version: 41
VERBOSE | Done with QEMU main loop
VERBOSE | User configuration saved to C:\Users\username\.android\avd\pixel_5_-_api_30.avd\emulator-user.ini
VERBOSE | Adb transition disconnected -> disconnected

I have searched and tried every solution for "failed to sync vcpu reg", "error while loading state for instance 0x0 of device 'goldfish_pipe'", but nothing has worked for me.  If I uninstall HAXM, the emulator runs albeit incredibly slowly.  If I install HAXM, the emulator crashes every time.
I suspected this may have had something to do with installing VirtualBox, but uninstalling that had no effect.

A: Seemingly contradictory to all of the information on the internet that says otherwise, enabling Virtual Machine Platform in Windows features fixed the issue.
https://stackoverflow.com/a/67664072/8169306
Credit to @angry_chloro_man for this solution.


text:
Q: ('serviceWorker' in navigator) not returning 'true' when read from file, true otherwise I have successfully built a Service Worker that controls a few pages in my Rails app (not easy). I've tested it and everything's working in the latest version of Google Chrome. However, if I try and add a conditional to the Service Worker registration script like so:
if ('serviceWorker' in navigator) #<-- this is what I'm talking about
  #registration stuff
else
  #Your browser does not support service workers

The conditional ('serviceWorker' in navigator) always returns false and the Service Worker registration script does not run. If I remove the conditional, everything works. If I type the conditional directly into Chrome's console, it returns true.
Does anyone have any idea what I'm doing wrong? My understanding is that if ('serviceWorker' in navigator) is the standard check to test a browser's compatibility with Service Workers. The registration script is being served up in its own file by my Rails application in development mode (and again, if I remove the conditional everything works).
Any ideas / avenues to explore are greatly appreciated!

A: I found the issue: I am using coffeescript instead of javascript (which is standard in Rails). Apparently in in coffeescript is very different than in in javascript. In coffeescript the correct line is:
if 'serviceWorker' of navigator


text:
Q: How to use Android Resources in Application class? I have a simple question, I can't get my resource drawable in my application class. Is there anyway to do it?
public class cApplication extends Application {

    @Override
    public void onCreate(){
        super.onCreate();
    }

    public void sendNotification(String message, Class<?> activityToOpen, int appId) {
        NotificationCompat.Builder mBuilder =
                new NotificationCompat.Builder(this)
                        .setSmallIcon(R.drawable.noticon)
                        .setContentTitle("My notification")
                        .setContentText("Hello World!");
        Intent resultIntent = new Intent(this, activityToOpen);
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
        stackBuilder.addParentStack(MainScreenActivity.class);
        stackBuilder.addNextIntent(resultIntent);
        PendingIntent resultPendingIntent =
                stackBuilder.getPendingIntent(
                        0,
                        PendingIntent.FLAG_UPDATE_CURRENT
                );
        mBuilder.setContentIntent(resultPendingIntent);
        NotificationManager mNotificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        mNotificationManager.notify(appId, mBuilder.build());
    }
}

I have a custom application class to handle some application stuff. I'm trying to delegate all the notification stuff to the Application class but I can't access my resource folder for the small icon.
.setSmallIcon(R.drawable.noticon)

R is not found. How would I resolve this issue or I would implement notification method in a service/activity?
Edit: I'm sorry. I realised that my application didn't rebuild properly, thus R is not found.

A: Sometimes you need clean and build to recreate the R file. Comment the line calling R class and uncomment after it has been generated

A: R is available in application class Try cleaning your project


text:
Q: Javascript: how to convert epoch to dd-mm-yyyy i have an epoch time: x = 1383483902000
I am trying to get a date like: dd-mm-yyyy and want to do this without additional library.
I have tried several ways and my last method end up like :
var date = new Date(Math.round(Number(x)));

but i get an ugly thing like: sun nov 03 2013 14:05:02 GMT+01:00

A: Use your date object to extract/format the parts you want:
var formattedDate = date.getUTCDate() + '-' + (date.getUTCMonth() + 1)+ '-' + date.getUTCFullYear()

A: The example below uses the UTC methods of the date object as you are dealing with epoch time (which is milliseconds since epoch in UTC):
var formatDate = function formatDate(date) {            // function for reusability
        var d = date.getUTCDate().toString(),           // getUTCDate() returns 1 - 31
            m = (date.getUTCMonth() + 1).toString(),    // getUTCMonth() returns 0 - 11
            y = date.getUTCFullYear().toString(),       // getUTCFullYear() returns a 4-digit year
            formatted = '';
        if (d.length === 1) {                           // pad to two digits if needed
            d = '0' + d;
        }
        if (m.length === 1) {                           // pad to two digits if needed
            m = '0' + m;
        }
        formatted = d + '-' + m + '-' + y;              // concatenate for output
        return formatted;
    },
    x = 1383483902000,                                  // sample time in ms since epoch
    d = new Date(x),                                    // convert to date object
    f = formatDate(d);                                  // pass to formatDate function to get dd-mm-yyyy
console.log(f);                                         // log output to console for testing

You can run this in the browser console as-is.

A: function formatDate(value: any): any{

    let date = new Date(Math.round(Number(value)));
    let day = ("0" + date.getDate()).slice(-2);
    let month = ("0" + (date.getMonth() + 1)).slice(-2);
    let formatDate = date.getFullYear()+"-"+(month)+"-"+(day) ;

    return formatDate;
}


text:
Q: VB code crashes only on one machine with (OS WIN 2008 R2) and runs successfully on all other machine, After dubugging what i found out is below Following is the code for your reference... I have a browse button when I click on this I set the listbox content After I added traces on this machine I found that it crashes when Me.csplStyles.ListIndex = p line gets executed
   Private Sub cmdLineStyle_Click()
         Dim f As New frmChartElementStyles
         f.Style = LineStyle // here it perfectly returns index,
   End Sub

   //Following function returns index successfully
   Private Property Get LineStyle() As Long
      Dim p As Object
      If Not Me.lvColumnsForProperties.SelectedItem Is Nothing Then
         Set p = m_colColumns(Me.lvColumnsForProperties.SelectedItem.key)
         LineStyle = p.LineStyle
      End If
   End Property

   Public Property Let Style(ByVal p As Long)
       **Me.csplStyles.ListIndex = p // Here it crashes**
   End Property

Let me tell you that this code runs fine on all the machines. There is only one machine where I face this problem.


text:
Q: converter endereço em coordenadas google maps api Estou fazendo um site no qual uso Google Maps API pra fazer a rota dos ônibus e preciso converter o endereço capturado em um input em coordenadas, e exibir elas em um outro input pra ir acompanhando (estou fazendo isso com um alert de js e ta me deixando louco).
estou pegando as coordenadas juntas no seguinte código:
    geocoder = new google.maps.Geocoder();
                geocoder.geocode({'address':start}, function(results, status){
                    if( status = google.maps.GeocoderStatus.OK){
                        latlng = results[0].geometry.location;
                        alert(latlng);
                    }

gostaria de pegar a lat e lng separadas em um input cada pra parar de usar o alert

A: O objeto "location" é uma instância da classe LatLng, acesse a referência
Logo, o código para buscar os campos de latitude e longitude separados fica:
document.getElementById('lat').value = latlng.lat();
document.getElementById('lng').value = latlng.lng();

Se seu objetivo é apenas debug, é mais simples usar a função console.log e observar o resultado no console do seu navegador.


text:
Q: Android studio double to date format I'm making a project on android studio.
I must convert a number into an hour, minutes and seconds date.
The number is: 0,18865386
The result must be: 04:31:40
I've obtained this date whit excel (used for test calc) just changing the cell format to HOURS but i don't understand how to calculate it.
Any solutions?

A: 1 corresponds to 24 hours.
In hours: 0,18865386 means 24 x 0,18865386 ~= 4,5 hours which corresponds to your 04:31:40.
If you need more precision, e.g. in seconds:
The number of seconds in a day = 24 x 60 x 60 = 86400.
Then 0,18865386 means 86400 x 0,18865386 = 16300 seconds = 04:31:40.


text:
Q: Visual Studio. Куда делась панель, где можно было смотреть ошибки комплилятора? Случайно нажал что-то и исчезла. Такое было не первый раз, но уже не могу вспомнить что необходимо сделать, чтобы вернулась. Английская версия студии.

A:
И иже с ним...................


text:
Q: SQL Group by Count and Date I have two tables
Table 1:
'table1Id' int,
'date' date

Table 2:
'table2Id' int,
'table1Id' int,
'switchVal' int DEFAULT NULL,
FOREIGN KEY 'table1Id' REFERENCES table1('table1Id')

How do I go about displaying the count table1Id grouped by date assuming that switchVal is not null?

A: Something like this:
SELECT        SUM(dbo.Table_1.table1Id) AS Expr1, dbo.Table_2.switch1val, dbo.Table_1.date
FROM            dbo.Table_1 INNER JOIN
                         dbo.Table_2 ON dbo.Table_1.table1Id = dbo.Table_2.table1id
GROUP BY dbo.Table_2.switch1val, dbo.Table_1.date
HAVING        (dbo.Table_2.switch1val IS NOT NULL)

A: You need to join the tables and group by based on the column table1Id.
Select t1.date, count(t1.table1Id) as 'Count' from Table1 t1 inner join Table2 t2 on t1.table1Id = t2.table1Id
where t2.[switchVal] is not null
group by t1.date


text:
Q: How to handle loads of rep recalc questions? In preparation for the soon to be implemented change in the rep system, and the necessary global rep-recalc and the ensuing onslaught of WTF!?! Where did all my rep go?? questions that are bound to be asked.  What is the best way to prevent dozens of duplicate questions here on MSO?
S Mark suggested in a comment to the original proposal to put up an alert bar on all the sites announcing the change.  Jeff declined saying that it would just be an invitation to support requests.
I suggest toning it down a bit.  How about an alert bar only here on meta?
It can be assumed that anyone on meta already knows about the changes and recalc and will just accept the notification and continue on their way.  Any other SOFU users who come here for support will get the notification as the first then when they log into MSO and hopefully have their question answered immediately.  Perhaps the bar could point to Jeff's original question proposing the idea or the blog post announcing it.
Is there a better way to handle the hordes of questions that are imminent?

A: Every user should be sent a message whenever a recalc is done on his account, letting him know about the recalc, and how much rep was lost or gain.
It's just a small matter of scripting.

A: I'd cheer them up with some waffles.

(source: mightysweet.com)

A: You can refer them to

*

*https://stackoverflow.com/reputation

*https://serverfault.com/reputation

*https://superuser.com/reputation

*https://meta.stackoverflow.com/reputation
see:  How do I audit my reputation?

A: Big orange bar on the top of the screen, "Where did my rep go!?"

A:
Thank you for your ongoing contributions to Stackoverflow. We may have previously overvalued said contributions, and have recently corrected this oversight by reducing your reputation score. We hope that this will help you better understand the diminished value of your work.

A: *

*Write a "rep recalculation FAQ".

*Close all questions as duplicates of that FAQ.

*Beer.

A: I agree about the alert bar only here on Meta, and would additionally suggest to show it only for users who are new to Meta or who haven't been to Meta in over x days. (x=30 ?)  You could have the "first time here? check the FAQ" bar as well as a bar saying "Are you here because you suddenly lost a lot of rep? Read this article"


text:
Q: What is rank deficiency, and how to deal with it? Fitting a logistic regression using lme4 ends with
Error in mer_finalize(ans) : Downdated X'X is not positive definite.

A likely cause of this error is apparently rank deficiency. What is rank deficiency, and how should I address it?

A: For the definition of the rank of a matrix, you can refer to any good textbook on linear algebra, or have a look at the Wikipedia page.
A $n \times p$ matrix $X$ is said to be full rank if $n \geq p$, and its columns are not a linear combination of each other. In that case, the $p \times p$ matrix $X^TX$ is positive definite, which implies that it has an inverse $(X^TX)^{-1}$.
If $X$ is not full rank, one of the columns is fully explained by the others, in the sense that it is a linear combination of the others. A trivial example is when a column is duplicated. This can also happen if you have a 0-1 variable and a column consists of only 0 or only 1. In that case, the rank of the matrix $X$ is less than $n$ and $X^TX$ has no inverse.
Since the solution of many regression problems (including logistic regression) involves the computation intermediate $(X^TX)^{-1}$, it is then impossible to estimate the parameters of the model. Out of curiosity, you can check here how this term is involved in the formula of multiple linear regression.
That was it for absolute rank deficiency. But sometimes the problem shows up when the matrix $X$ is "almost" not full rank, as extensively detailed by @woodchips. This problem is usually referred to as multicollinearity. This issue is fairly common, you can find out more on how to deal with it on related posts here and there.

A: user974's answer is fantastic from a modelling perspective and gui11aume's answer is fantastic from a mathematical perspective. I want to refine the former answer strictly from a mixed modelling perspective: specifically a generalized mixed modelling (GLMM) perspective. As you can see, you have referenced the R function mer_finalize which is in the fantastic lme4 package. You also say that you are fitting a logistic regression model.
There are many issues that crop up with such types of numerical algorithms. The issue of the matrix structure of the model matrix of fixed effects is certainly worth considering, as user974 alluded to. But this is very easy to assess, simply calculated the model.matrix of your formula= and data= arguments in a model and take its determinant using the det function. Random effects, however, greatly complicate the interpretation, numerical estimation routine, and inference on the fixed effects (what you typically think of as regression coefficients in a "regular" regression model).
Suppose in the simplest case you are only fitted a random intercepts model. Then you are basically considering there to be thousands of unmeasured sources of heterogeneity that are held constant in repeated measures within clusters. You estimate a "grand" intercept, but account for the heterogeneity by assuming that the cluster-specific intercepts have some mean0 normal distribution. The intercepts are iteratively estimated and used to update model effects until convergence is achieved (the log likelihood--or an approximation of it--is maximized). The mixed model is very easy to envision, but mathematically the likelihood is very complex and prone to issues with singularities, local minimae, and boundary points (odds ratios = 0 or infinity). Mixed models do not have quadratic likelihoods like canonical GLMs.
Unfortunately, Venerables and Ripley did not invest much into diagnostics for converge-fails like yours. It is practically impossible to even speculate at the myriad of possible errors leading to such a message. Consider, then, the types of diagnostics I use below:

*

*How many observations are there per cluster?

*What are the results from a marginal model fit using GEE?

*What is the ICC of the clusters? Is the within cluster heterogeneity close to the between cluster heterogeneity?

*Fit a 1-step estimator and look at the estimated random effects. Are they approximately normal?

*Fit the Bayesian mixed model and look at the posterior distribution for the fixed effects. Do they appear to have an approximately normal distribution?

*Look at a panel plot of the clusters showing exposure or regressor of interest against the outcome using a smoother. Are the trends consistent and clear or are there many possible ways that such trends may be explained? (e.g. what is the "risk" among unexposed subjects, does the exposure appear protective or harmful?)

*Is it possible to restrict the sample to subjects only having a sufficient number of observations-per-person (say, n=5 or n=10) to estimate the "ideal" treatment effect?

Alternately, you can consider some different modelling approaches:

*

*Are there few enough clusters or time points that you can use a fixed effect (such as group indicators or a polynomial time effect) to model the cluster level/autoregressive heterogeneity?

*Is a marginal model appropriate (using a GEE to improve efficiency of standard error estimation, but still using only fixed effects)

*Could a Bayesian model with an informative prior on the random effects improve estimation?

A: I also kept getting warnings about rank deficiency. In my case it seemed to be caused by the fact that I had a categorical variable where some of the categories were empty/not represented in the training set. When I created a category called other for the different low-frequency categories, I got rid of the warning.
This was when building a linear regression with the train() function from caret. Here is the warning:
Warning messages:
In predict.lm(modelFit, newdata) :
prediction from a rank-deficient fit may be misleading

A: Rank deficiency in this context says there is insufficient information contained in your data to estimate the model you desire. It stems from many origins. I'll talk here about modeling in a fairly general context, rather than explicitly logistic regression, but everything still applies to the specific context.
The deficiency may stem from simply too little data. In general, you cannot uniquely estimate n parameters with less than n data points. That does not mean that all you need are n points, as if there is any noise in the process, you would get rather poor results. You need more data to help the algorithm to choose a solution that will represent all of the data, in a minimum error sense. This is why we use least squares tools. How much data do you need? I was always asked that question in a past life, and the answer was more than you have, or as much as you can get. :)
Sometimes you may have more data than you need, but some (too many) points are replicates. Replication is GOOD in the sense that it helps to reduce the noise, but it does not help to increase numerical rank. Thus, suppose you have only two data points. You cannot estimate a unique quadratic model through the points. A million replicates of each point will still not allow you to fit more than a straight line, through what are still only effectively a pair of points. Essentially, replication does not add information content. All it does is decrease noise at locations where you already have information.
Sometimes you have information in the wrong places. For example, you cannot fit a two dimensional quadratic model if all you have are points that all lie in a straight line in two dimensions. That is, suppose you have points scattered only along the line x = y in the plane, and you wish to fit a model for the surface z(x,y). Even with zillions of points (not even replicates) will you have sufficient information to intelligently estimate more than a constant model. Amazingly, this is a common problem that I've seen in sampled data. The user wonders why they cannot build a good model. The problem is built into the very data they have sampled.
Sometimes it is simply choice of model. This can be viewed as "not enough data", but from the other side. You wish to estimate a complicated model, but have provided insufficient data to do so.
In all of the above instances the answer is to get more data, sampled intelligently from places that will provide information about the process that you currently lack. Design of experiments is a good place to start.
However, even good data is sometimes inadequate, at least numerically so. (Why do bad things happen to good data?) The problem here may be model related. It may lie in nothing more than a poor choice of units. It may stem from the computer programming done to solve the problem. (Ugh! Where to start?)
First, lets talk about units and scaling. Suppose I try to solve a problem where one variable is MANY orders of magnitude larger than another. For example, suppose I have a problem that involves my height and my shoe size. I'll measure my height in nanometers. So my height would be roughly 1.78 billion (1.78e9) nanometers. Of course, I'll choose to measure my shoe size in kilo-parsecs, so 9.14e-21 kilo-parsecs. When you do regression modeling, linear regression is all about linear algebra, which involves linear combinations of variables. The problem here is these numbers are different by hugely many orders of magnitude (and not even the same units.) The mathematics will fail when a computer program tries to add and subtract numbers that vary by so many orders of magnitude (for a double precision number, that absolute limit is roughly 16 powers of 10.)
The trick is usually to use common units, but on some problems even that is an issue when variables vary by too many orders of magnitude. More important is to scale your numbers to be similar in magnitude.
Next, you may see problems with big numbers and small variation in those numbers. Thus, suppose you try to build a moderately high order polynomial model with data where your inputs all lie in the interval [1,2]. Squaring, cubing, etc., numbers that are on the order of 1 or 2 will cause no problems when working in double precision arithmetic. Alternatively, add 1e12 to every number. In theory, the mathematics will allow this. All it does is shift any polynomial model we build on the x-axis. It would have exactly the same shape, but be translated by 1e12 to the right. In practice, the linear algebra will fail miserably due to rank deficiency problems. You have done nothing but translate the data, but suddenly you start to see singular matrices popping up.
Usually the comment made will be a suggestion to "center and scale your data". Effectively this says to shift and scale the data so that it has a mean near zero and a standard deviation that is roughly 1. That will greatly improve the conditioning of most polynomial models, reducing the rank deficiency issues.
Other reasons for rank deficiency exist. In some cases it is built directly into the model. For example, suppose I provide the derivative of a function, can I uniquely infer the function itself? Of course not, as integration involves a constant of integration, an unknown parameter that is generally inferred by knowledge of the value of the function at some point. In fact, this sometimes arises in estimation problems too, where the singularity of a system is derived from the fundamental nature of the system under study.
I surely left out a few of the many reasons for rank deficiency in a linear system, and I've prattled along for too long now. Hopefully I managed to explain those I covered in simple terms, and a way to alleviate the problem.


text:
Q: how to use JSR-303 annotations to validate PropertySources I'm interested in using JSR-303 (Bean Validation) annotations such as @NonNull to validate Spring PropertySources, specifically configuration files.
I'm wondering if Spring has support for this out-of-the-box, and if not, how can I write such a framework?  Should I validate PropertySource or PropertySources?
Ideally, this framework would not depend on Spring so it works for folks using other DI frameworks.
Any tips would be greatly appreciated.


text:
Q: Make CGRectMake Frame Stick to Bottom I am trying to have a view that expands to fit the remaining height of the screen. The issue is that I am trying to do this on both iPhone 4 and iPhone 5 layouts.
What I would like to do is have my CGRectMake code so that the frame just anchors to the bottom of the main view. Is there a way to do something like this? Thanks!
Heres my webView CGRectMake code:
webView.frame = CGRectMake(0, 167, 320, 313);

A: Try to use auto layout here to avoid hardcoding.
webView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
webView.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:webView];

NSDictionary *viewsDict = @{@"webView" : webView};
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-167-[webView]-0-|"
                  options:0 metrics:nil views:viewsDict]];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[webView]-0-|"
                  options:0 metrics:nil views:viewsDict]];

You will also avoid layout issues when performing autorotating

A: You can make a reference to the views frame to accomplish this.
webView.frame = CGRectMake(0, 167, 320, self.view.frame.size.height - 167);

A: Well if you have a fixed starting height it's too easy:
int startHeight = 167;
int frameHeight = self.view.frame.size.height - startHeight;
webView.frame = CGRectMake(0, startHeight, 320, frameHeight);

What this does is to get the view's height, then it deducts the start offset of the Window.
For this to work, the code needs to be executed after the view has been displayed on the UIWindow, which means you need to execute it in viewDidAppear and not viewDidLoad.

A: If you give up on setting frame rects directly and embrace auto layout, this will be easy.


text:
Q: How to allow standard user to install software in Sierra? Thank you in advance for the wealth of knowledge on this site.  I am setting up a new MacBook Pro with Sierra and need to ensure the standard user account is able to install software and make changes to printing.  Besides these two items it needs to be a standard account.  With the research I have done it seems the security authorizationdb would be used however I am unsure on how to use this command correctly.  Can someone please advise on how to achieve this?

A: There is this jamf post. The solution there is to tweak 1th. the authorisation database an 2th. allow standard users to add/remove printers by adding them to the lpadmin group.

*

*

security authorizationdb write system.preferences allow
security authorizationdb write system.preferences.printing allow

*

dseditgroup -o edit -a $username -t user lpadmin
Refs:
JAMF
DSSW
terminal macos


text:
Q: Leak of Malloc 16 Bytes in C / Objective-C When I profile my code with Instruments, it shows a leak of Malloc 16 bytes from this function (below), but I never used malloc in this function. Is there a place in this function where I should free some resources?
It may look like a lot of code, but there is really only the variables counts and counts2 as possible offenders I think.
+ (int) trimArray: (NSMutableArray*) source above: (short) max andMin: (short) min
{
    int counts[6][7];
    int counts2[6][7];
    for (int i=0;i<=5;i++)
    {
        for (int ii=0;ii<7;ii++)
        {
            counts[i][ii] = 0;
            counts2[i][ii] = 0;
        }
    }

    int capacity = (int)[source count]/max;
    if (capacity <2)
        capacity = 2;

    NSMutableArray *itemsToRemove = [[NSMutableArray alloc] initWithCapacity:capacity];

    int week,dow,count1,count2;
    EntryTimeItem *item;
    NSEnumerator *e;

    e = [source objectEnumerator];
    while (item = [e nextObject])
    {
        week = item.week_number;
        dow  = item.day_of_the_week;
        if (week >=0 && week <6 && dow >=0 && dow <7)
        {
            counts[week][dow]++;
        }
    }

    e = [source objectEnumerator];
    while (item = [e nextObject])
    {
        week = item.week_number;
        dow  = item.day_of_the_week;
        if (week >= 0 && week < 6 && dow >= 0 && dow < 7)
        {
            count2 = counts2[week][dow];
            count1 = counts[week][dow];
            if (count1 > max)
            {
                if (!count2)
                {
                    item.time = -1;
                    item.align = NSCenterTextAlignment;
                    item.label = [NSString stringWithFormat:@"%d entries",count1];
                }
                else {
                    // remove this item if it is after the first item which
                // was converted to a placeholder for all the items
                    [itemsToRemove addObject:item];
                }
            }
            counts2[week][dow]++;
        }
    }

    e = [itemsToRemove objectEnumerator];
    while (item = [e nextObject])
    {
        [source removeObject:item];
    }

    int count_extra_events = 0;
    for (int i=0;i<7;i++)
    {
        int count_events2 = 0;
        for (int ii = 0; ii < 6; ii++)
        {
            int count3 = counts[ii][i];
            if (count3 < max && count3 > min)
                count_events2 += count3 - min;
        }
        // store the greatest value found sofar
        if (count_events2 > count_extra_events)
        {
            count_extra_events = count_events2;
        }
    }

    return count_extra_events;
}

A: The problem appears to stem from the line:
NSMutableArray *itemsToRemove = [[NSMutableArray alloc] initWithCapacity:capacity];

Please check if there is anyway, the resource itemsToRemove can be freed.


text:
Q: Share and save Image of ImageView? I have app that has two buttons one for sharing a image and one for saving it to memory
save button working perfectly but sharing button not working .
here is the save button :
public void exportImage () {
    if (this.mImageDrawableSet == false) {
        this.mSaveImageOnDisplay = true;
        return;
    }

    try {
        final Bitmap bitmap = getImageBitmap();
        if (bitmap == null) {
            Toast.makeText(getActivity(), "Something Went Wrong, Please Try Again!", Toast.LENGTH_SHORT).show();
            return;
        }

        final File dir = new File(Environment.getExternalStorageDirectory(), super.getResources().getString(R.string.config_external_storage_folder));

        if (!dir.exists()) {
            dir.mkdirs();
        }

        final File img = new File(dir, this.mNode.name + ".png");
        if (img.exists()) {
            img.delete();
        }

        final OutputStream outStream = new FileOutputStream(img);
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outStream);
        outStream.flush();
        outStream.close();

        super.getActivity().sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + dir.toString())));
        Toast.makeText(getActivity(), "Wallpaper Saved To, " + img.toString() + "!", Toast.LENGTH_LONG).show();
    } catch (Exception e) {
        Log.e(TAG, "", e);
        Toast.makeText(getActivity(), "Something Went Wrong, Please Try Again!", Toast.LENGTH_SHORT).show();
    }
}

and here is the share section :
public void shareimage () {
    if (this.mImageDrawableSet == false) {
        this.mApplyImageOnDisplay = true;
        return;
    }

    try {
        final Bitmap bitmap = getImageBitmap();
        if (bitmap == null) {
            Toast.makeText(getActivity(), "Something Went Wrong, Please Try Again!", Toast.LENGTH_SHORT).show();
            return;
        }
        File root = Environment.getExternalStorageDirectory();
        File cachePath = new File(root.getAbsolutePath() + "/DCIM/Camera/image.jpg");

            cachePath.createNewFile();
            FileOutputStream ostream = new FileOutputStream(cachePath);
            bitmap.compress(CompressFormat.JPEG, 100, ostream);
            ostream.close();
            Intent share = new Intent(Intent.ACTION_SEND);
            share.setType("image/*");
            share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(cachePath));
            startActivity(Intent.createChooser(share,"Share via"));
        } catch (Exception e) {
            e.printStackTrace();
            Toast.makeText(getActivity(), "Something Went Wrong, Please Try Again!", Toast.LENGTH_SHORT).show();
        }
    }

and nothing is shown on logcat and i just get something wrong toast .
permissions are correct .
logcat
02-15 16:10:50.527: W/System.err(2033):     at      android.support.v4.app.Watson.onMenuItemSelected(Watson.java:126)
02-15 16:10:50.539: W/System.err(2033):     at com.actionbarsherlock.ActionBarSherlock.callbackOptionsItemSelected(ActionBarSherlock.java:604)
02-15 16:10:50.539: W/System.err(2033):     at com.actionbarsherlock.internal.ActionBarSherlockNative.dispatchOptionsItemSelected(ActionBarSherlockNative.java:92)
02-15 16:10:50.539: W/System.err(2033):     at com.actionbarsherlock.app.SherlockFragmentActivity.onMenuItemSelected(SherlockFragmentActivity.java:204)
02-15 16:10:50.539: W/System.err(2033):     at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:986)
02-15 16:10:50.539: W/System.err(2033):     at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
02-15 16:10:50.539: W/System.err(2033):     at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152)
02-15 16:10:50.539: W/System.err(2033):     at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
02-15 16:10:50.539: W/System.err(2033):     at com.android.internal.view.menu.ActionMenuView.invokeItem(ActionMenuView.java:547)
02-15 16:10:50.539: W/System.err(2033):     at com.android.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:115)
02-15 16:10:50.539: W/System.err(2033):     at android.view.View.performClick(View.java:4240)
02-15 16:10:50.539: W/System.err(2033):     at android.view.View$PerformClick.run(View.java:17721)
02-15 16:10:50.543: W/System.err(2033):     at android.os.Handler.handleCallback(Handler.java:730)
02-15 16:10:50.543: W/System.err(2033):     at android.os.Handler.dispatchMessage(Handler.java:92)
02-15 16:10:50.543: W/System.err(2033):     at android.os.Looper.loop(Looper.java:137)
02-15 16:10:50.543: W/System.err(2033):     at android.app.ActivityThread.main(ActivityThread.java:5103)
02-15 16:10:50.543: W/System.err(2033):     at java.lang.reflect.Method.invokeNative(Native Method)
02-15 16:10:50.543: W/System.err(2033):     at java.lang.reflect.Method.invoke(Method.java:525)
02-15 16:10:50.543: W/System.err(2033):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
02-15 16:10:50.551: W/System.err(2033):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
02-15 16:10:50.551: W/System.err(2033):     at dalvik.system.NativeStart.main(Native Method)
02-15 16:10:50.551: W/System.err(2033): Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
02-15 16:10:50.555: W/System.err(2033):     at libcore.io.Posix.open(Native Method)
02-15 16:10:50.555: W/System.err(2033):     at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
02-15 16:10:50.555: W/System.err(2033):     at java.io.File.createNewFile(File.java:941)
02-15 16:10:50.559: W/System.err(2033):     ... 23 more

A: i found it in case anyone needed it
final shareimage()
public void shareimage () {
    if (this.mImageDrawableSet == false) {
        this.mApplyImageOnDisplay = true;
        return;
    }

    try {
        final Bitmap bitmap = getImageBitmap();
        if (bitmap == null) {
            Toast.makeText(getActivity(), "Something Went Wrong, Please Try Again!1", Toast.LENGTH_SHORT).show();
            return;
        }
        final File dir = new File(Environment.getExternalStorageDirectory(), super.getResources().getString(R.string.config_external_storage_folder));

        if (!dir.exists()) {
            dir.mkdirs();
        }

        final File img = new File(dir, this.mNode.name + ".png");
        if (img.exists()) {
            img.delete();
        }
        final OutputStream outStream = new FileOutputStream(img);
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outStream);
        outStream.flush();
        outStream.close();
            Intent share = new Intent(Intent.ACTION_SEND);
            share.setType("image/*");
            share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(img));
            startActivity(Intent.createChooser(share,"Share via"));
        } catch (Exception e) {
            e.printStackTrace();
            Toast.makeText(getActivity(), "Something Went Wrong, Please Try Again!2", Toast.LENGTH_SHORT).show();
        }
    }

A: I guess that my code is smaller + since it uses openFileOutput() method from Context + MODE_WORLD_READABLE for temporary file it doesn't need any permissions:
    ImageView iv = (ImageView )adapter.getmCurrentView();
    String fileName = "image.jpg";
    iv.setDrawingCacheEnabled(true);
    Bitmap bitmap = iv.getDrawingCache();
    try
    {
        FileOutputStream ostream = getActivity().openFileOutput( fileName, Context.MODE_WORLD_READABLE);
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, ostream);
        ostream.close();
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }

    Intent share = new Intent(Intent.ACTION_SEND);
    share.setType("image/*");
    share.putExtra(Intent.EXTRA_SUBJECT, "Great photo from Poland!");
    share.putExtra(Intent.EXTRA_TEXT, "Hi,  I'm sharing with you this great picture!");
    share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile( new File( getActivity().getFileStreamPath( fileName).getAbsolutePath())));
    startActivity(Intent.createChooser(share,"Share via"));

A: I am making a wild guess now, but looks like here:
File root = Environment.getExternalStorageDirectory();

you have forgot to call
root.mkdirs();

afterwards. I mean are you sure at that point of your code that your file + directory exists?


text:
Q: Setting the value of a spreadsheet cell using a script I have created a script that runs on a timed trigger once a day, and its purpose is to copy a template spreadsheet and rename it using the current date.  In addition, I would like to set the value of a specific cell within the newly created spreadsheet to the current date.
var date = Utilities.formatDate(new Date(), 'EST', 'MMddyy');
var newLiveFeedName = "Live Feed ("+date+")";
var newLiveFeed = currentLiveFeedTemplate.makeCopy(newLiveFeedName);
newLiveFeed.SpreadsheetApp.getSheetByName("Summary").getRange('G2').setValue(date);

I am getting an error that indicates that the getSheetByName() function is undefined.  What am I missing?

A: newLiveFeed is a spreadsheet object, so try simply like that :
(assuming that  currentLiveFeedTemplate is the ActiveSpreadsheet())
var date = Utilities.formatDate(new Date(), 'EST', 'MMddyy');
var newLiveFeedName = "Live Feed ("+date+")";
var newLiveFeed = currentLiveFeedTemplate.copy(newLiveFeedName);
newLiveFeed.getSheetByName("Summary").getRange('G2').setValue(date);


text:
Q: String formatting prob for making database value inside a file I have a bean class which does maintain user data:
soppose I have created a postgresql DB table like this:
StringBuffer sqlStr = new StringBuffer();
sqlStr.append("CREATE TABLE Users ("
        user_id         bigint,
        username        character varying NOT NULL,
        biography       character varying NOT NULL
);

& I want to make a query command and inject my String data inside it:
    sqlStr.append("INSERT INTO users(" +
            "user_id, username, biography)" +
            "\n\tVALUES (" + user.getID()+ "," + user.getUsername() + "," + user.getBiography()+");";

my problem is for example if the data coming from my method has quote or double quote or "," my command will become wrong suppose that the user biography is something like this :

hello, I'm Mr X an "IT Pro" ...

If I run my application and save the output inside a file called query.sql I can't use it because my query command is wrong because of quote & double quote, something like this:
INSERT INTO users(userid, username, biography)
     VALUES(2, 'Mehdi', 'hello, I'm Mr X an "IT Pro" ..');

how Can I fix this problem ?

A: You should never ever use the above method for constructing SQL queries.
"Why not?" you ask, well; where to start. The classic example is Bobby Tables, the more general problem is SQL injection. This leaves your program open to attack but also to random failure - like the situation you describe.
Now, the solution. Always use PreparedStatement to construct your query. In your example
final String query = "INSERT INTO users(user_id, username, biography) VALUES (?,?,?)";
final PreparedStatement ps = con.prepareStatement(query);
ps.setInt(1, user.getID());
ps.setString(2, user.getUsername());
ps.setString(3, user.getBiography());
ps.executeUpdate();

A much nicer syntax to use with is the the SET syntax rather than the traditional VALUES syntax. The query would then look like
final String query = "INSERT INTO users SET user_id = ?, username = ?, biography = ?";

EDIT
The OP is building a query for a script file, not executing a query in the code.
There is a utility class in Apache Commons Lang, StringEscapeUtils. This has an escapeSql method. Looking at the source code, all this does is escape single quotes with another single quote.
This works if you build your queries with single quotes:
VALUES (" + user.getID()+ ",'" + user.getUsername() + "'...

So the query, once the example value is inserted will go from:
VALUES (10 ,'hello, I'm Mr X an "IT Pro"'...

Will become
VALUES (10 ,'hello, I''m Mr X an "IT Pro"'...

The apostrophe in "I'm" is now escaped and harmless.
Note that you obviously need to escape the values and not the query, so (assuming you have a static import for the class)
VALUES (" + user.getID()+ ",'" + escapeSql(user.getUsername()) + "'...

But does not escape other sql characters, percent signs for example.
This is really a stop-gap measure to make the code work while you come up with a more robust solution. And you should come up with a more robust solution.

A: Why dont you use PreparedStatement? That will also give you better performance as the SQL will be pre-compiled on DB side.
Or
You can escape the quotes using
String.replaceAll http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#replaceAll(java.lang.String, java.lang.String)


text:
Q: Prolog, how to read value pro function for use in other function I have this function:
func1(X).

After execution func1(a) return value X = n.
This is a second function:
other_func(z).

After execution other_func(z), it returns true or false.
And I need to use value from func1(a) to get a return value in the other function.
Example:
final_func(X) :- func1(X) = R , other_func(R).

but always returns false.

A: I solved with other solution,
final_func(C) :- (func1(X,m) -> other_func(m) ; other_func(n)).

My problem is solved, but this is not correct solution because it only works for  one case.